|
例例1 標準的なアプリケーションのディレクトリ構造
- index.php
- .htaccess
+ conf
|- application.ini // アプリケーションの設定
- application/
- Bootstrap.php
+ controllers
- Index.php // デフォルトのコントローラ
+ views
|+ index
- index.phtml // デフォルトアクション用のビューテンプレート
+ modules
- library
- models
- plugins
例2 エントリ トップディレクトリの index.php が、アプリケーションの唯一の入り口です。 index.php へのすべてのリクエストをリダイレクトしなければいけません (Apache+mod_php なら .htaccess を使えます)。 例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",
)
}
例4 アプリケーションの設定 [yaf] ; APPLICATION_PATH は index.php で定義した定数 application.directory=APPLICATION_PATH "/application/" ; product セクションは yaf セクションを継承する [product:yaf] foo=bar 例5 デフォルトのコントローラ 例6 デフォルトのビューテンプレート 例7 アプリケーションの実行 上の例の出力は、 たとえば以下のようになります。 <html> <head> <title>Hello World</title> </head> <body> hello world </body> </html>
|