Kohana

Kohana 2.2 の Validation で callbacks を追加する注意点

callbacks に追加するユーザー関数がクラスメソッドの場合、アクセス修飾子は public にする必要がある。 よく考えれば、その通りなのだが…。 アクセス修飾子を private や protected にしているとエラーが発生する

Kohana 2.2 の Validation クラスの使い方

基本的な使い方。 '090-0300-0000', 'url' => 'http://www.goog…

Kohana 2.1 から 2.2 は大幅な変更が加えられていた

Kohana のドキュメントと動作の振る舞いが異なることに気がつき、2.1 と 2.2 のソースを比較してみた。 結果、大幅な変更が加えられていたことがわかった。 2.1 から 2.2 への変更点 2.1 to 2.2 Upgrading 特に Validation ライブラリの変更点が大きく、現在…

Kohana で POST メソッドを利用する。

http://localhost/kohana/ を Kohana のルートとする POST データを投げる URL は http://localhost/kohana/index.php/post/recieve/ とする。コントローラー名は「post」、メソッド名は「recieve」となる。 post.html <form method="post" action="/kohana/index.php/post/recieve/"> <label for="mail">メールアドレス<br /> <input id="mail" type="text" name="mail"></label></form>

Kohana をインストールして、よく忘れる設定

application/cache と application/logs ディレクトリの書き込み権限を修正しないとエラーが発生する。 % cd KOHANA_HOME/application % ls -l total 0 drwxr-xr-x@ 11 satounaotaka admin 374 7 22 19:18 . drwxr-xr-x 5 satounaotaka admin 272 7 22 19:20…

Kohana でデータベースに接続する設定をする

Kohana のドキュメントには、 To configure the database there should be a file database.php in your application/config directory. If it isn't there you should copy it from the system/config directory. データベースの接続を設定するには、applic…

ルートディレクトリにアクセスした場合のデフォルトのコントローラーを設定する。

例えば、Kohana を DocumentRoot/kohana に設置したとする。そして、Kohana にアクセスする URL を http://www.example.com/kohana/ とする。 この URL にアクセスした場合のデフォルトのコントローラーを設定する方法を記しておく。 デフォルトのコントロー…

URL から index.php を除く

すっかり忘れていたので、備忘録として残す。 RewriteEngine on RewriteBase /myapplication/ RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] .htaccess ファイルを作成し、Kohana のトップディレクトリに配置する…

View を実装する

参考にしたドキュメント Kohana View Kohana Controllers CodeIgniter View(英語が苦手な人向け) CodeIgniter Controller(英語が苦手な人向け) hello クラス用の view を作成する application/views/hello.php として保存する。 <h1></h1> <p>こんにちは! さん。</p> hello …

Kohana で Hello, World!

CodeIgniter とは異なり、Controller の命名規約が異なる。 CodeIgniter はコントローラー名がクラス名になるが、Kohana の場合は Controller名 + _Conroller になる。 を application/controllers に hello.php として保存する。 そして、http://localhost…

Kohana の .htaccess について

CodeIgniter の .htaccess の設定と同様に Kohana でも行なう。 これを読んでから、Kohana の設定(Removing index.php From URLs)を読めば、英語がよくわからなくても理解できる。 Kohana のチュートリアルを参考にして、への直接アクセスを禁止することもで…

Kohana の application ディクレクトリと system ディレクトリ を Apache の DocumentRoot から外す

この作業を行うのは、セキュリティ上の理由から実施する。 Apache の DocumentRoot に Kohana の application や system ディレクトリがあるということは、不特定多数の人がそれらのディレクトリにアクセスできることを表す。このことは、例えばデータベース…

Kohana と CodeIgniter の違い

Notes on Choosing a PHP Framework: A Quick Comparison of CodeIgniter and Kohana | thislab.com - Web development and design by Fred Wu.の要約。 誤訳あり。 Kohana と CodeIgniter の簡単な比較 PHP のフレームワークで、CakePHP を使ってみた。しか…

Kohana ことはじめ 2

Make the application/logs directory writeable. Chmod to 666.application/logs ディレクトリを書き込み可能にするために、パーミッションを 666 に設定する。 Make the application/cache directory writeable if you use the cache library. Chmod to 66…

Kohana ことはじめ 1

CodeIgniter の設定ファイル application/config/config.php application/config/database.php Kohana の設定ファイル application/config/config.php system/config/database.php

Kohana ことはじめ 3

You should always try to create custom versions of the following files: * system/config/routes.php - set your $config['_default'] to your default controller * system/config/encryption.php - change the default $config['key'] * modules/auth/…

PHP フレームワーク Kohana

CodeIgniter のフォーク版フレームワーク。 Home – Kohana: Swift, Secure, and Small PHP 5 Framework Kohana : せつないぶろぐ Kohana | thislab.com - Web development and design by Fred Wu.