Example #1 一锟斤拷锟斤拷锟酵碉拷应锟斤拷目录锟结构
- index.php - .htaccess + conf |- application.ini //application config - application/ - Bootstrap.php + controllers - Index.php //default controller + views |+ index - index.phtml //view template for default action + modules - library - models - plugins
Example #2 锟斤拷锟斤拷募锟�
锟斤拷锟斤拷目录锟铰碉拷index.php锟斤拷锟斤拷锟斤拷应锟矫碉拷唯一锟斤拷冢锟接︼拷冒锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷囟锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷Apache+php_mod模式锟铰匡拷锟斤拷使锟斤拷.htaccess锟斤拷锟斤拷
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . "/conf/application.ini");
$app->bootstrap() //call bootstrap methods defined in Bootstrap.php
->run();
?>
Example #3 锟斤拷写锟斤拷锟斤拷
#for apache (.htaccess) RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php #for 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; } } #for lighttpd $HTTP["host"] =~ "(www.)?domain.com$" { url.rewrite = ( "^/(.+)/?$" => "/index.php/$1", ) }
Example #4 应锟斤拷锟斤拷锟斤拷锟侥硷拷
[yaf] ;APPLICATION_PATH is the constant defined in index.php application.directory=APPLICATION_PATH "/application/" ;product section inherit from yaf section [product:yaf] foo=bar
Example #5 默锟较匡拷锟斤拷锟斤拷
<?php
class IndexController extends Yaf_Controller_Abstract {
/* default action */
public function indexAction() {
$this->_view->word = "hello world";
//or
// $this->getView()->word = "hello world";
}
}
?>
Example #6 默锟斤拷锟斤拷图锟侥硷拷
<html>
<head>
<title>Hello World</title>
</head>
<body>
<?php echo $word;?>
</body>
</html>
Example #7 锟斤拷锟斤拷应锟斤拷
锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�
<html> <head> <title>Hello World</title> </head> <body> hello world </body> </html>
Note:
锟斤拷yaf@github锟斤拷锟斤拷Yaf锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷也锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷印锟�