環境
参考にさせて頂いたページ
bakeによる高速開発(1/8):初心者のためのCakePHP2.0 プログラミング入門
Bakeでコード生成 — CakePHP Cookbook 2.x ドキュメント
パソコン活用の豆知識 » CakePHPにおいて、timezone関連でワーニングエラーが発生
vagrantその18 cakephpの初期設定をしてみる - MOTOMICHI WORKS BLOG
まず準備
- cakephp-2.6.1.zipを解凍して配置
- bake/app/Config/core.phpのランダム文字列を2箇所編集
- bake/app/Config/database.phpを編集
- bake/app/Pluginに、DebugKitフォルダを配置
- app/Config/bootstrap.phpの一番下の行に
CakePlugin::load('DebugKit');
を追記する - app/Controller/AppController.phpのAppControllerクラスに追記
下記コードを追記
//DebugKitのコンポーネントを追加
var $components = array('DebugKit.Toolbar');
(DebugKitのon/offは、app/Config/core.phpの中のConfigure::write('debug', 2);
のところで切り替える)
cake bakeを実行してみたけどcakeコマンドが使えなかった
参考ページ
bakeによる高速開発(2/8):初心者のためのCakePHP2.0 プログラミング入門
にならって、bake/app/Console
まで移動した。
cake bake
してみたら
-bash: cake: command not found
こうしたらcake bakeできた
Bakeでコード生成 — CakePHP Cookbook 2.x ドキュメント
にならって
./cake bake
としたらいけた。
Windowsはどうなのかな。
コマンドは実行できたけど、Warningが出てた
./cake bakeは実行できたけどWarning出てた。
下記のような表示がされたんだけど、タイムゾーン設定をしていないせいみたい。
motomichi-no-MacBook-Air:Console motomichishigeru$ ./cake bake
Warning: strtotime(): 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 'Asia/Tokyo' for 'JST/9.0/no DST' instead in /Users/motomichishigeru/Desktop/all/git_repos_all/bitbucket/motomichi_mti/bp_20140708/0003-cakephp/bake/lib/Cake/Cache/CacheEngine.php on line 60
Warning: strtotime(): 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 'Asia/Tokyo' for 'JST/9.0/no DST' instead in /Users/motomichishigeru/Desktop/all/git_repos_all/bitbucket/motomichi_mti/bp_20140708/0003-cakephp/bake/lib/Cake/Cache/CacheEngine.php on line 60
Welcome to CakePHP v2.6.1 Console
---------------------------------------------------------------
App : app
Path: /Users/motomichishigeru/Desktop/all/git_repos_all/bitbucket/motomichi_mti/bp_20140708/0003-cakephp/bake/app/
---------------------------------------------------------------
Interactive Bake Shell
---------------------------------------------------------------
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
>
タイムゾーンを設定する
パソコン活用の豆知識 » CakePHPにおいて、timezone関連でワーニングエラーが発生
を参考に、bake/app/Config/core.phpに
date_default_timezone_set(‘Asia/Tokyo’);
を記述した。
参考にさせて頂いたページはdate_default_timezone_set(‘Asis/Tokyo’);となっていて、間違っているのでdate_default_timezone_set(‘Asia/Tokyo’);
としたんだけど、まだWarningが出る。
結果的に
を参考に以下のようにしたらWarningは出なかった。
date_default_timezone_set('UTC');
または
date_default_timezone_set('Japan');
だとWarningは出ない。
php.iniの設定を変更する方法もあるとのこと。
Database Configurationについてはまた次回。