Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
forked fromlaruence/yaf

Fast php framework written in c, built in php extension

License

NotificationsYou must be signed in to change notification settings

yulonghu/yaf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

DocumentRoot

You should setDocumentRoot toapplication/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)

<?phpdefine("APPLICATION_PATH",dirname(dirname(__FILE__)));$app  =newYaf_Application(APPLICATION_PATH ."/conf/application.ini");$app->bootstrap()//call bootstrap methods defined in Bootstrap.php    ->run();

Rewrite rules

Apache

#.htaccessRewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteRule .* 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 supportedapplication.directory = APPLICATION_PATH"/application/"

Alternatively, you can use a PHP array instead:

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

default controller

In Yaf, the default controller is namedIndexController:

<?phpclass IndexControllerextends Yaf_Controller_Abstract {// default action namepublicfunctionindexAction() {$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><?phpecho$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

More

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

About

Fast php framework written in c, built in php extension

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C71.1%
  • PHP26.1%
  • Smarty1.4%
  • C++0.6%
  • M40.5%
  • JavaScript0.2%
  • Shell0.1%

[8]ページ先頭

©2009-2025 Movatter.jp