環境
- Mac
- FuelPHP 1.8
- 参考サイト
クイックインストール
$ curl get.fuelphp.com/oil | sh
適当にページを作ってみる
$ oil create test
Cloning into './test'...
to retrieve a token. It will be stored in "/Users/yoshiyuki_sakamoto/.composer/auth.json" for future use by Composer.
Token (hidden):
GitHubのトークンを求められたので、 https://github.com/settings/tokens に行き、Generate New Token する。多分 public_repo
だけチェックしてあれば十分なので、これでトークンを作成する。
作成されたトークンをCopyして貼り付ける。hiddenなので何も表示されないが、Enterを押すと続きが始まるはず。
しばらくして
Error - date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in COREPATH/classes/fuel.php on line 162
と出てきた。なんかデフォルトタイムゾーンがおかしいっぽい。エラーでそのままググったら http://qiita.com/maximum80/items/d8c841ccdaf6f8106b3f とかがヒットした。
$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: (none)
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: (none)
Loaded Configration File
が (none)
になっているので、こいつを生成してやって、タイムゾーンの設定を書く。
/etc/php.ini.default
というのがあるので、これを /etc/php.ini
にコピーしてタイムゾーンの設定を追記することにする。ただ、コピーしたままだとアクセス権限が r--r--r--
になっており、書き込みが出来なかったので、アクセス権も付与する。
$ cd /etc
$ sudo cp php.ini.default php.ini
$ sudo chown 744 php.ini
php.ini
の中に [date] という部分があり、 date.timezone=
がコメントアウトしてあるので書き足す。
date.timezone = "Asia/Tokyo"
$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: (none)
使ってみる
適当にプロジェクトを作ってみる
$ oil create test
しばらくしたら test
ディレクトリが作成される。その中の fuel
がアプリケーション本体のようだ。更にその中の app
にアプリケーションのあれこれが入っている。 config
も app
の中に入っていて、これは他のフレームワークと異なっているので、所見ではconfigが何処にあるかわからないかもしれない。 classes
の下に controller
と model
、 presenter
がある。app
直下じゃないのと、単数形であることに注意が必要っぽい。 presenter
というのはviewとcontrollerの間を持っているもののように見える。一般的に想像される、htmlが書いてあるviewは app/view
にある。 public/index.php
が多分ルーティングの設定になっていると思われる。
http://www.buildinsider.net/web/bookphplib100/096 によると、
- 設定ファイルでの細かな指定がなく、ディレクトリとクラス名で役割を指定
- 必要なクラスを自動で呼び出すオートローダーが実装されており、require文/include文が不要
- Controllerからロジックを分離するViewModelの仕組みがあり、ソースコードの肥大化を防止
- 上記のとおりシンプルな構成のため、動作が高速
とのこと。
デフォルトで controller/welcome.php
というのがあるから、多分デフォルトでも何かが動くのであろう。動かしてみる。
sudo ln -s /..../test/public /Library/WebServer/Documents/fuel
``
そして、 http://localhost/fuel にアクセスすると...
Error!
Fuel\Core\PhpErrorException [ Error ]:
date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.
というわけで `fuel/app/config/config.php` で、 `'default_timezone' => none` と書いてある箇所がありますので、ここのコメントアウトを外してリロードしてみます。
```php
'default_timezone' => 'Asia/Tokyo'
リロードしたら動きました。いかにもbootstrapなページが表示されます。