Skip to content
A fast php framework written in c, built in php-ext
C PHP Other
Latest commit 6a3dd2d @laruence Update doc
Failed to load latest commit information.
configs Remove SVN staffs
requests Remove SVN staffs
responses prepare release 2.3.5
routes Attempt to fix segfault with delim
tests module name
tools added some TODOs.. fixed typos and a possible bug fix
travis Fix typo
views Remove SVN staffs
.gitattributes attributes
.travis.yml Add PHP 5.5 into test cycles
CREDITS 1. Fixed issues #4
EXPERIMENTAL initial commit
LICENSE Add LICENSE file Update doc Missing files, fix #82
config.m4 Fixed issue #189 Error in pecl upgrade to get the newest stable yaf
config.w32 try to fix windws build
package.xml Fixed issue #163 (forward from init controller)
php_yaf.h back to dev (2.3.6-dev)
yaf.c Remove SVN staffs
yaf.dsp Add working folder to include path
yaf.php initial commit
yaf_action.c Remove SVN staffs
yaf_action.h Remove SVN staffs
yaf_application.c Remove SVN staffs
yaf_application.h Remove SVN staffs
yaf_bootstrap.c Remove SVN staffs
yaf_bootstrap.h Remove SVN staffs
yaf_config.c Remove SVN staffs
yaf_config.h Remove SVN staffs
yaf_controller.c module name
yaf_controller.h Remove SVN staffs
yaf_dispatcher.c Fixed issue #163 (forward from init controller)
yaf_dispatcher.h Remove SVN staffs
yaf_exception.c Remove SVN staffs
yaf_exception.h Remove SVN staffs
yaf_loader.c Fixed invalid read(segfault) with php-5.4
yaf_loader.h Remove SVN staffs
yaf_logo.h Remove SVN staffs
yaf_namespace.h Remove SVN staffs
yaf_plugin.c Remove SVN staffs
yaf_plugin.h Remove SVN staffs
yaf_registry.c Remove SVN staffs
yaf_registry.h Remove SVN staffs
yaf_request.c Remove SVN staffs
yaf_request.h Remove SVN staffs
yaf_response.c Remove SVN staffs
yaf_response.h Remove SVN staffs
yaf_router.c Remove SVN staffs
yaf_router.h Remove SVN staffs
yaf_session.c Remove SVN staffs
yaf_session.h Remove SVN staffs
yaf_view.c Remove SVN staffs
yaf_view.h Remove SVN staffs

Yaf - Yet Another Framework

Build Status

PHP framework written in c and built as a PHP extension.


  • PHP 5.2 +


Install Yaf

Yaf is an PECL extension, thus you can simply install it by:

$pecl install yaf

Compile Yaf in Linux

$./configure --with-php-config=/path/to/php-config
$make && make install


Yaf manual could be found at:

IRC #php.yaf


you could find a documented prototype script here:



A classic Application directory layout:

- .htaccess // Rewrite rules
+ public
  | - index.php // Application entry
  | + css
  | + js
  | + img
+ conf
  | - application.ini // Configure 
- application/
  - Bootstrap.php   // Bootstrap
  + controllers
     - Index.php // Default controller
  + views    
     |+ index   
        - index.phtml // View template for default controller
  - library
  - models  // Models
  - plugins // Plugins


you should set DocumentRoot to application/public, thus only the public folder can be accessed by user


index.php in the public directory is the only way in of the application, you should rewrite all request to it(you can use .htaccess in Apache+php mod)

define("APPLICATION_PATH",  dirname(dirname(__FILE__)));

$app  = new Yaf_Application(APPLICATION_PATH . "/conf/application.ini");
$app->bootstrap() //call bootstrap methods defined in Bootstrap.php

Rewrite rules


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php


server {
  listen ****;
  root   document_root;
  index  index.php index.html index.htm;

  if (!-e $request_filename) {
    rewrite ^/(.*)  /index.php/$1 last;


$HTTP["host"] =~ "(www.)?$" {
  url.rewrite = (
     "^/(.+)/?$"  => "/index.php/$1",


application.ini is the application config file

;CONSTANTS is supported = APPLICATION_PATH "/application/" 

alternatively, you can use a PHP array instead:

$config = array(
   "application" => array(
       "directory" => application_path . "/application/",

$app  = new yaf_application($config);

default controller

In Yaf, the default controller is named IndexController:

class IndexController extends Yaf_Controller_Abstract {
   // default action name
   public function indexAction() {  
        $this->getView()->content = "Hello World";

view script

The view script for default controller and default action is in the application/views/index/index.phtml, Yaf provides a simple view engineer called "Yaf_View_Simple", which supported the view template written by PHP.

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

Run the Applicatioin


you can generate the example above by using Yaf Code Generator:


More info could be found at Yaf Manual:

Something went wrong with that request. Please try again.