CakePHPを市販本を見ながら触っており、フレームワークの良さを実感しています。作り込む場所が極端に減ったところや、scaffold による成果物などに感動しているところです。そんな中、本に書いていない設定をいくつか行いましたのでメモしておきます。
CakePHP ログ出力用パーミッション
テスト的に使っている過程で、コーディングミスでエラーがあった際に、「/usr/local/apache2/test/app/tmp/logs/error.log」にファイルを作れない、と画面にエラーが出たので、以下のようにパーミッション設定を行いました。
# chmod 777 /usr/local/apache2/test/app/tmp/logs/
すると、この場所に error.log が吐かれるようになりました。
PHPUnit のインストール
# which pear /usr/local/bin/pear # pear config-set auto_discover 1 config-set succeeded # pear install pear.phpunit.de/PHPUnit Attempting to discover channel "pear.phpunit.de"... downloading channel.xml ... Starting to download channel.xml (804 bytes) ....done: 804 bytes Auto-discovered channel "pear.phpunit.de", alias "phpunit", adding to registry Attempting to discover channel "pear.symfony-project.com"... downloading channel.xml ... Starting to download channel.xml (865 bytes) ...done: 865 bytes Auto-discovered channel "pear.symfony-project.com", alias "symfony", adding to registry Did not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically phpunit/PHPUnit can optionally use package "phpunit/PHP_Invoker" (version >= 1.1.0) phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5) phpunit/PHPUnit_MockObject can optionally use PHP extension "soap" downloading PHPUnit-3.6.12.tgz ... Starting to download PHPUnit-3.6.12.tgz (119,220 bytes) ...done: 119,220 bytes downloading File_Iterator-1.3.1.tgz ... Starting to download File_Iterator-1.3.1.tgz (5,157 bytes) ...done: 5,157 bytes downloading Text_Template-1.1.1.tgz ... Starting to download Text_Template-1.1.1.tgz (3,622 bytes) ...done: 3,622 bytes downloading PHP_CodeCoverage-1.1.3.tgz ... Starting to download PHP_CodeCoverage-1.1.3.tgz (132,726 bytes) ...done: 132,726 bytes downloading PHP_Timer-1.0.2.tgz ... Starting to download PHP_Timer-1.0.2.tgz (3,686 bytes) ...done: 3,686 bytes downloading PHPUnit_MockObject-1.1.1.tgz ... Starting to download PHPUnit_MockObject-1.1.1.tgz (19,897 bytes) ...done: 19,897 bytes downloading YAML-1.0.6.tgz ... Starting to download YAML-1.0.6.tgz (10,010 bytes) ...done: 10,010 bytes downloading PHP_TokenStream-1.1.3.tgz ... Starting to download PHP_TokenStream-1.1.3.tgz (9,860 bytes) ...done: 9,860 bytes install ok: channel://pear.phpunit.de/File_Iterator-1.3.1 install ok: channel://pear.phpunit.de/Text_Template-1.1.1 install ok: channel://pear.phpunit.de/PHP_Timer-1.0.2 install ok: channel://pear.symfony-project.com/YAML-1.0.6 install ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.3 install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.1.3 install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.1.1 install ok: channel://pear.phpunit.de/PHPUnit-3.6.12 #
以上で、CakePHPのテストページにアクセスできるようになりました。
Linux での bake 起動
app/Console/ の中にある cake(実行権限あり)を「bake」オプションを付けて起動します。
# ./cake bake Welcome to CakePHP v2.2.1 Console --------------------------------------------------------------- App : app Path: /usr/local/apache2/test/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) > q #
これでガンガン用意できるのは感動です。