The symfony Cookbook

デフォルトのディレクトリ構造をカスタマイズする方法

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


About

You are currently reading "The symfony Cookbook" which is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License license.

Master symfony

Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).
trainings.sensiolabs.com

Books on symfony

Learn more about symfony with the official guides.
books.sensiolabs.com

L'audit Qualité par SensioLabs

200 points de contrôle de votre applicatif web.
audit.sensiolabs.com
symfony training
Be trained by symfony experts
May 29: Paris (Web Development with Symfony2 - Français)
May 31: Paris (Mastering Symfony2 - Français)
Jun 06: Paris (Introduction to Symfony2 - Français)
Jun 06: Paris (Introduction to Symfony2 - English)
Jun 06: Paris (Going Further with Symfony2 - English)
and more...

Search


powered by google
You are currently browsing "The symfony Cookbook" in Japanese for the 1.1 version - Switch to version: - Switch to language:
Creative Commons License This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License.
Translation of this work into another language is explicitly allowed.
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

フレームワークを利用する大きな利点の1つは複数のプロジェクトでまたがった一貫した構造です。すべてのプロジェクトは同じコーディング規約および同じディレクトリ構造を共有します。この構造によって同じプロジェクトで同時に作業できます。しかし開発されたアプリケーションのメンテナンス可能性も強化されます。あなたが最初に開発をしなかったsymfonyプロジェクトをメンテナンスするように誰かに頼まれたときに、すべてのファイルがどこに保存されているのか理解しているのですぐにハックを始めることができます。

しかし時には、symfonyによって提供されたディレクトリ構造をカスタマイズできることが必要です。2つのまったく異なる例を取り上げてみましょう。

最初に、共用ホスト環境で、web rootディレクトリがpublic_htmlという名前の共用ホスト環境でsymfonyのプロジェクトをホストする場合を考えてみましょう。ProjectConfigurationクラスを編集することで、デフォルトのweb rootディレクトリをwebからpublic_htmlに変更することはとても簡単です:

// config/ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    $this->setWebDir($this->getRootDir().'/../public_html');
  }
}

別の例を取り上げてみましょう。あなたのsymfonyプロジェクトが厳しいセキュリティルールを持つ大企業でホストされているとします。そしていくつかの特定のディレクトリ(たとえば/tmp)以外ではアプリケーションはディスクに書き込みできません。symfonyは2つのディレクトリ(cachelog)のみに書き込みするので、これらのディレクトリを/tmpの下に設置するためにProjectConfigurationクラスを再び更新するのはとても簡単です:

// config/ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    $this->setCacheDir('/tmp/myproject/cache');
    $this->setLogDir('/tmp/myproject/log');
  }
}

setCacheDir()メソッドは定数sf_cache_dirを変更するだけでなくキャッシュに関連したすべての定数: sf_app_base_cache_dirsf_app_cache_dirsf_template_cache_dirsf_i18n_cache_dirsf_config_cache_dirsf_test_cache_dir、とsf_module_cache_dirも変更します。

大事なことを言い忘れていました。設定クラスはsymfony CLIにも使われるので、これらすべてのカスタマイズはsymfonyに搭載されたタスクおよびあなた独自のタスクにも有効です。

symfony 1.1の新しい設定クラスのおかげで、フレームワークの設定作業はとても楽になりました。

Questions & Feedback

If you find a typo or an error, please register and open a ticket.

If you need support or have a technical question, please post to the official user mailing-list.