Cakephp1.3に入門して最初にやること

今まで2.0を使っていたのですが、Ktaiライブラリを使いたくて1.3を使ってみることにしました。ほぼ2.0と変わらないのですが、一応メモっておこうと思います。
環境はMacOSX 10.6.8、XAMPP 1.7.3 CakePHP 1.3.14 です。

内容

ダウンロード

http://cakephp.jp/
からダウンロードします。2012/3現在1.3.14が最新の安定版です。
ダウンロードして解凍し、そのまま/Applications/XAMPP/xamppfiles/htdocs/の中に突っ込みます。ついでにフォルダ名は"Cake1.3"に変更します。localhost/Cake1.3/ にアクセスするとデフォルト画面が確認できました。

Warningだらけなのでここから潰していきます。

Warning対応

/app/tmp/のパーミッション

Warning (512): ~ is not writable [CORE/cake/libs/cache/file.php, line 281] への対応で/app/tmp/以下のディレクトリに書き込み権限を設定します。
シンプルに707に設定すればよし。
※以下のパーミッションに関する記述は理解が不十分な情報です
tmpディレクトリ以下をwebサーバと同一グループにした方がセキュリティ的にベターという情報を見つけ試してみます。

$ cd /Applications/XAMPP/xamppfiles/htdocs/Cake1.3/app/tmp/

$ sudo chgrp -R apachegroup ./

webサーバのグループは、apacheの場合httpd.confから確認できます。
#

User user

Group group

</IfModule>

これでいくつかWarningが消えて、"Your tmp directory is writable."となりました。

database.phpの作成

まずはデータベースを用意します。
mysqlにログイン

$ /Applications/XAMPP/xamppfiles/bin/mysql -u username -p

Enter password: パスワードを入力

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.44 Source distribution

データベースをutf-8で作成してmysqlを終了
mysql> create database dbname character set utf8;

Query OK, 1 row affected (0.01 sec)



mysql> exit

Bye

database.php.defaultをdatabase.phpにリネームして、編集
$ sudo vim /Applications/XAMPP/xamppfiles/htdocs/Cake1.3/app/config/database.php

class DATABASE_CONFIG {



        var $default = array(

                'driver' => 'mysql',

                'persistent' => false,

                'host' => 'localhost',

                'login' => 'username',

                'password' => 'password',

                'database' => 'dbname',

                'prefix' => '',

                //を消す'encoding' => 'utf8',

        );

ここまでくればあと一歩です。

Security.saltの変更

core.php内下記の部分を編集

$ sudo vim /Applications/XAMPP/xamppfiles/htdocs/Cake1.3/app/config/database.php



/**

 * A random string used in security hashing methods.

 */

   Configure::write('Security.salt', '適当な文字列');



/**

 * A random numeric string (digits only) used to encrypt/decrypt strings.

 */

   Configure::write('Security.cipherSeed', '適当な数字列');


これで完了です。やっと開発だー