TopGit tracks laruence/yaf on GitHub as part of the Backend family. The project has 4.5k stars. Fast php framework written in c, built in php extension
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Yaf is a PHP framework with high performance. It is written in C and built as a PHP extension.
When to use Yaf
Yaf is not "yet another PHP framework" — it's a C framework exposed through PHP. Every class, every router match, every dispatch cycle runs in compiled C code rather than interpreted PHP. The result: constant overhead per request measured in microseconds, not milliseconds.
This matters most in two scenarios:
High-traffic applications where framework bootstrap overhead becomes the dominant cost. Yaf eliminates the class-file loading cascade of Composer-based frameworks — there are no PHP files to require for the framework itself. new Yaf_Application() is instant; the router and dispatcher are already loaded in the extension's shared memory.
Long-lived services (Swoole, RoadRunner, ReactPHP) where you want your framework to not be the bottleneck. Yaf has no global state pollution issues across requests — each request gets a clean dispatch cycle with no static caches to leak.
Yaf pairs naturally with the rest of the "Yet Another" ecosystem:
Use Yaconf for static configuration — it eliminates the INI parse overhead that Yaf_Config_Ini pays on every request.
Use Yac for runtime caching — database results, computed data, HTML fragments. All three share the same "local first, zero dependency, C-native" design philosophy.
Requirement
PHP 7.0+ (master branch)
PHP 5.2+ (php5 branch)
Install
Install via PECL
Yaf is a PECL extension, which means you can simply install it by:
$ pecl install yaf
Compile from source
$ /path/to/phpize
$ ./configure --with-php-config=/path/to/php-config
$ make && make install
Runtime Configuration
INI Setting
Default
Description
yaf.environ
"product"
Default environment name. This maps to the INI section loaded from application.ini
yaf.library
""
Global library directory, searched after the application's local library
yaf.forward_limit
5
Maximum number of forward() calls allowed in a single request. Prevents infinite loops
yaf.name_suffix
1
When 1, classes use suffix naming (IndexController). When 0, uses prefix naming (Controller_Index)
yaf.name_separator
""
In multi-module setups, replaces the underscore between module and class name. E.g. with "/": Admin/IndexController instead of Admin_IndexController
yaf.use_namespace
0
When 1, enables namespaced class names (Yaf\Application, Yaf\Controller_Abstract, etc.)
yaf.action_prefer
0
When 1, actions are resolved as standalone Yaf_Action_Abstract classes in an actions/ subdirectory instead of controller methods
yaf.lowcase_path
0
When 1, all paths are lowercased before class loading (e.g. controllers/Index.php → controllers/index.php)
yaf.use_spl_autoload
0
When 1, Yaf registers itself on the SPL autoload stack instead of replacing __autoload. Useful when coexisting with other autoloaders
Documentation
Yaf manual can be found at: http://www.php.net/manual/en/book.yaf.php
For IDE
A documented prototype script can be found at: https://github.com/elad-yosifon/php-yaf-doc
Tutorial
Application Directory Layout
A classic single-module application directory layout is:
Set DocumentRoot to application/public, so only the public folder is accessible from the web.
index.php
index.php in the public directory is the only way into the application. You should rewrite all requests to it (using .htaccess in Apache + mod_php, or the equivalent in your web server).
<?php
define("APPLICATION_PATH", dirname(dirname(__FILE__)));
$app = new Yaf_Application(APPLICATION_PATH . "/conf/application.ini");
$app->bootstrap() // call bootstrap methods defined in Bootstrap.php
->run();
Bootstrap
A minimal Bootstrap.php looks like this:
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initConfig(Yaf_Dispatcher $dispatcher)
{
// put your init logic here
}
}
Bootstrap auto-calling: Any method in Bootstrap whose name starts with _init is automatically called in definition order by Yaf_Application::bootstrap(). Each method receives the Yaf_Dispatcher instance as its first argument.
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initConfig(Yaf_Dispatcher $dispatcher)
{
// called first
}
public function _initPlugin(Yaf_Dispatcher $dispatcher)
{
// called second
}
public function _initRoute(Yaf_Dispatcher $dispatcher)
{
// called third
}
// This is NOT auto-called — doesn't start with _init
public function helperMethod()
{
}
}
Rewrite Rules
Apache
#.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
In Yaf, the default controller is named IndexController:
<?php
class IndexController extends Yaf_Controller_Abstract
{
// default action name
public function indexAction()
{
$this->getView()->content = "Hello World";
}
}
View Script
The view script for the default controller and default action is application/views/index/index.phtml. Yaf provides a simple view engine called Yaf_View_Simple, which supports view templates written in PHP:
Performance tip: If you have a large amount of static configuration, consider using Yaconf — a persistent configuration container that keeps configs in shared memory across the entire PHP lifecycle, providing significantly faster access than parsing INI files on every request.
Plugins
Yaf supports a plugin hook system via Yaf_Plugin_Abstract. Override any of 7 hooks:
<?php
class UserPlugin extends Yaf_Plugin_Abstract
{
public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {}
public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {}
public function dispatchLoopStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {}
public function preDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {}
public function postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {}
public function dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {}
public function preResponse(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {}
}
Common use: storing objects initialized in Bootstrap (e.g. a database connection, a logger instance) so controllers can access them without re-initializing.
Yaf_Session
Yaf_Session is a namespaced wrapper around PHP's native $_SESSION. It implements ArrayAccess, Iterator, and Countable, and supports property-style access.
$session = Yaf_Session::getInstance();
$session->start();
// All equivalent:
$session->set("user", $data);
$session["user"] = $data;
$session->user = $data;
$session->get("user");
$session["user"];
$session->user;
$session->has("user");
isset($session->user);
$session->del("user");
unset($session["user"]);
unset($session->user);
$session->clear(); // removes all keys
count($session); // number of keys
More
More info can be found at the Yaf Manual: http://www.php.net/manual/en/book.yaf.php
The most recent commit recorded on laruence/yaf was 1.0 years ago, based on the GitHub push timestamp. The repository has 1.4k forks — one of the better signals of community interest.
How does laruence/yaf compare to other Backend projects?
laruence/yaf is tracked by TopGit in the Backend category, with 4.5k GitHub stars and written in C. Browse the Backend topic page on TopGit to compare it against similar projects by stars and activity.
How many stars does laruence/yaf have?
laruence/yaf has 4.5k GitHub stars — refresh the page for the live number, or check github.com/laruence/yaf. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What is laruence/yaf?
laruence/yaf (laruence/yaf) is a C project on GitHub. From the project's own README: Fast php framework written in c, built in php extension
What language is laruence/yaf written in?
laruence/yaf is written primarily in C. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is laruence/yaf associated with?
GitHub's repository topics for laruence/yaf: "c", "php", "php-framework", "yaf". TopGit's editorial category is Backend.
Why is laruence/yaf categorized under Backend?
TopGit places laruence/yaf in the Backend category based on its GitHub topics and description (tagged: "c", "php", "php-framework"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Curious whether yaf is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about yaf.