Giter Site home page Giter Site logo

yodphp's Introduction

yodphp - Yod Framework for PHP

It is a simple PHP framework which is written in C and build as PHP extension.

Requirement

  • PHP 5.2 +

Tutorial

installation

  • Compiling Yod:
$PHP_BIN/phpize
./configure --with-php-config=$PHP_BIN/php-config
make
make install
  • Compiling Yod with debug mode:
$PHP_BIN/phpize
./configure --enable-yod-debug --with-php-config=$PHP_BIN/php-config
make
make install
  • Cross compiling Yod for i686-linux:
$PHP_BIN/phpize
./configure --enable-yod-debug --with-php-config=$PHP_BIN/php-config \
CCFLAGS="-m32" CPPFLAGS="-m32" CXXFLAGS="-m32" CFLAGS="-m32"
make
make install

layout

  • A classic Application directory layout:
- index.php	// Application entry
+ public
+ yodphp
	+ drivers	// Database Drivers
	- yodphp.php	// Yodphp entry
+ app
	+ actions	// Other actions
	+ configs
		- config.php	// Configure 
	+ controllers
		- IndexController.php	// Default controller
	+ extends	// Extends
	+ models	// Models
		- DemoModel.php
	+ views
		+ index	// View templates for default controller
			- index.php

  • Multiple entry Application directory layout:
- index.php	// Application index entry
- hello.php	// Application hello entry
+ public
+ app

index.php

index.php is the application entry

<?php
//set_time_limit(0);
error_reporting(E_ALL);
date_default_timezone_set('Asia/Shanghai');

defined('YOD_RUNPATH') or define('YOD_RUNPATH', dirname(__FILE__) . '/app');

hello.php

hello.php is the application hello entry

<?php
//set_time_limit(0);
error_reporting(E_ALL);
date_default_timezone_set('Asia/Shanghai');

defined('YOD_RUNPATH') or define('YOD_RUNPATH', dirname(__FILE__) . '/app');

class HelloController extends Yod_Controller
{
	public function indexAction()
	{
		$this->assign('content', 'Hello World');
		$this->display('/index/index');
	}

	public function errorAction()
	{
		echo '<pre>';
		print_r($this);
	}
}

config.php

config.php is the application config file

<?php
return array(
	// db_dsn
	'db_dsn' => array(
		'type'   => 'pdo',
		'pdsn'   => 'mysql:host=localhost;port=3306;dbname=test',
		'host'   => 'localhost',
		'port'   => '3306',
		'user'   => 'root',
		'pass'   => '123456',
		'dbname' => 'test',
		'prefix' => 'yod_',
		'charset' => 'utf8',
		// slaves
		'slaves' => array(
			array(
				'dsn'    => 'mysql:host=localhost;port=3306;dbname=test',
				'user'   => 'root',
				'pass'   => '123456',
			),
		),
	),
	// tpl_data
	'tpl_data' => array(
		'_PUBLIC_' => '/public/'
	),
);

default controller

In Yodphp, the default controller is named IndexController

<?php
class IndexController extends Yod_Controller {
	// default action name
	public function indexAction() {
		$this->assign($content, 'Hello World');
		$this->display();
	}
}

###view script The view script for default controller and default action is in the app/views/index/index.php

<html>
  <head>
    <title>Hello World</title>
  </head>
  <body>
    <?php echo $content; ?>
  </body>
</html>

yodphp's People

Contributors

yodstar avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.