All Projects → laruence → Yaf

laruence / Yaf

Licence: other
Fast php framework written in c, built in php extension

Programming Languages

c
50402 projects - #5 most used programming language
PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Yaf

oas
ระบบบัญชีออนไลน์ Online Accounting System (OAS)
Stars: ✭ 51 (-98.85%)
Mutual labels:  php-framework
Bingo-Framework
MVC framework for PHP
Stars: ✭ 15 (-99.66%)
Mutual labels:  php-framework
miniPHP
A small, simple PHP MVC framework skeleton that encapsulates a lot of features surrounded with powerful security layers.
Stars: ✭ 147 (-96.69%)
Mutual labels:  php-framework
framework
The Bow Framework
Stars: ✭ 33 (-99.26%)
Mutual labels:  php-framework
leafMVC
MVC "Framework" created from Leaf PHP Framework
Stars: ✭ 25 (-99.44%)
Mutual labels:  php-framework
cloudnative-hyperf
A cloud native hyperf skeleton, featuring kubernetes
Stars: ✭ 36 (-99.19%)
Mutual labels:  php-framework
Lightweight-PHP-Framework-For-Web-and-APIs
Simple PHP framework that helps you quickly understand and write simple APIs.
Stars: ✭ 24 (-99.46%)
Mutual labels:  php-framework
Koseven
Koseven a Kohana fork compatible with PHP7
Stars: ✭ 332 (-92.53%)
Mutual labels:  php-framework
startmvc
超轻量php框架 lightweight php framework
Stars: ✭ 25 (-99.44%)
Mutual labels:  php-framework
PHPFlask
🍶 Flask for PHP
Stars: ✭ 15 (-99.66%)
Mutual labels:  php-framework
OwOFrame
A lightweight MVC framework for PHP
Stars: ✭ 46 (-98.97%)
Mutual labels:  php-framework
W
Framework pédagogique de la WebForce3
Stars: ✭ 10 (-99.78%)
Mutual labels:  php-framework
framework
PHP Rapid Application Development Framework
Stars: ✭ 237 (-94.67%)
Mutual labels:  php-framework
broadworks-ocip
PHP Framework for interacting with the Broadworks OCI Provisioning API
Stars: ✭ 26 (-99.42%)
Mutual labels:  php-framework
Php Security Check List
PHP Security Check List [ EN ] 🌋 ☣️
Stars: ✭ 262 (-94.11%)
Mutual labels:  php-framework
betephp
BetePHP - A simple PHP Framework that just work.
Stars: ✭ 77 (-98.27%)
Mutual labels:  php-framework
yii2-material-theme
Material Theme for Yii2
Stars: ✭ 15 (-99.66%)
Mutual labels:  php-framework
Medoo
The lightweight PHP database framework to accelerate the development.
Stars: ✭ 4,463 (+0.38%)
Mutual labels:  php-framework
Symlex
A lean framework stack for agile Web development based on Symfony and Vuetify
Stars: ✭ 278 (-93.75%)
Mutual labels:  php-framework
YurunPHP
YurunPHP是宇润软件专为懒人开发者设计的一款开源PHP框架,基于MVC动态分层架构,开发者可以根据需要自行扩充分层。宇润PHP交流群:17916227
Stars: ✭ 30 (-99.33%)
Mutual labels:  php-framework

Yaf - Yet Another Framework

Build Status Build status Build Status

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

Requirement

Install

Install Yaf

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

$pecl install yaf

Compile Yaf in Linux

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

Document

Yaf manual could be found at: http://www.php.net/manual/en/book.yaf.php

IRC

efnet.org #php.yaf

For IDE

You could find a documented prototype script here: https://github.com/elad-yosifon/php-yaf-doc

Tutorial

layout

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 // libraries
  + models  // Models
  + plugins // Plugins

DocumentRoot

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

index.php

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)

<?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();

Rewrite rules

Apache

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

Nginx

server {
  listen ****;
  server_name  domain.com;
  root   document_root;
  index  index.php index.html index.htm;
 
  if (!-e $request_filename) {
    rewrite ^/(.*)  /index.php/$1 last;
  }
}

Lighttpd

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

application.ini

application.ini is the application config file

[product]
;CONSTANTS is supported
application.directory = APPLICATION_PATH "/application/" 

Alternatively, you can use a PHP array instead:

<?php
$config = array(
   "application" => array(
       "directory" => application_path . "/application/",
    ),
);

$app  = new yaf_application($config);
....
  

default controller

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 default controller and default action is in the application/views/index/index.phtml, Yaf provides a simple view engine called "Yaf_View_Simple", which support the view template written in PHP.

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

Run the Application

http://www.yourhostname.com/

Alternative

You can generate the example above by using Yaf Code Generator: https://github.com/laruence/php-yaf/tree/master/tools/cg

./yaf_cg -d output_directory [-a application_name] [--namespace]

More

More info could be found at Yaf Manual: http://www.php.net/manual/en/book.yaf.php

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].