このサイトはCakePHPの組み込みライブラリ「Inflector」を試すサイトです。
※ 当サイトはCakePHP 1.2.6を使用しています。
変換したい文字列を入力して、「送信」ボタンを押して下さい。
Inflectorを実行した結果
| Inflector::pluralize | restaurants_photos |
|---|---|
| Inflector::singularize | restaurants_photo |
| Inflector::camelize | RestaurantsPhotos |
| Inflector::underscore | restaurants_photos |
| Inflector::humanize | Restaurants Photos |
| Inflector::tableize | restaurants_photos |
| Inflector::classify | RestaurantsPhoto |
| Inflector::variable | restaurantsPhotos |
| Inflector::slug | restaurants_photos |
CakePHP 規約
| model | ||
|---|---|---|
| モデル名 | RestaurantsPhoto | 単語始まりが大文字、単数形 Inflector::singularize(Inflector::classify($word)); |
| モデルのファイル名 | restaurants_photo.php | アンダースコア、全部小文字、単数形 Inflector::singularize(Inflector::slug(strtolower($word))).'.php'; |
| Table Name | restaurants_photos | アンダースコア、全部小文字、複数形 Inflector::pluralize(Inflector::slug(strtolower($word))); |
| controller | ||
|---|---|---|
| コントローラー名 | RestaurantsPhotos | 単語始まりが大文字、複数形 Inflector::pluralize(Inflector::classify($word)); |
| コントローラーのクラス名 | RestaurantsPhotosController | 単語始まりが大文字、複数形、最後にControllerを追加 Inflector::pluralize(Inflector::classify($word)).'Controller'; |
| コントローラーのファイル名 | restaurants_photos_controller.php | アンダースコア、全部小文字、複数形、最後に_controllerを追加 Inflector::pluralize(Inflector::slug(strtolower($word))).'_controller.php'; |
| uses用の名前 | RestaurantsPhoto | モデル名 Inflector::singularize(Inflector::classify($word)); |
| view | ||
|---|---|---|
| ビューフォルダ名 | restaurants_photos | アンダースコア、全部小文字、複数形 Inflector::pluralize(Inflector::slug(strtolower($word))); |
| ビューのファイル名 | restaurants_photo.php | アンダースコア、全部小文字、単数形 Inflector::singularize(Inflector::slug(strtolower($word))).'.php'; |
「Inflector」とは?
Inflector クラスは文字列を扱い、複数形やキャメル記法といったように単語のバリエーションをハンドルする操作を行うものです。例えば…
Inflector::pluralize('example');
上記の様なコードは「examples」という値を返します。(公式サイトより)
参考情報
- Inflector :: 実用的な各種の組み込みライブラリ :: マニュアル :: 1.2 Collection :: The Cookbook
- クラスのメソッド :: Inflector :: 実用的な各種の組み込みライブラリ :: マニュアル :: 1.2 Collection :: The Cookbook
- 文字列変換に便利!CakePHPの組み込みライブラリ(Inflector) | バシャログ。
- Inflectorクラス分析。規約上の単語変化について - CPA-LABテクニカル
- Inflectorのバグ?要注意単語集。単数・複数変化もの - CPA-LABテクニカル
- [Cakephp]Inflectorのメソッドって何があったっけ?なメモ | HappyQuality