| | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot |
例例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 を使えます)。
<?php例3 リライトルール
# 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",
)
}
例4 アプリケーションの設定 [yaf] ; APPLICATION_PATH は index.php で定義した定数 application.directory=APPLICATION_PATH "/application/" ; product セクションは yaf セクションを継承する [product:yaf] foo=bar 例5 デフォルトのコントローラ
<?php例6 デフォルトのビューテンプレート
<html>例7 アプリケーションの実行結果 上の例の出力は、 たとえば以下のようになります。 <html> <head> <title>Hello World</title> </head> <body> hello world </body> </html>
|
|
各種マニュアル:
PHPマニュアル |
PEARマニュアル |
Smarty(英語)マニュアル |
PHP-GTKマニュアル |
「例」をGoogle検索
|