?symfonyのインストール手順

symfonyのインストール手順

本家のドキュメントを読む

http://www.symfony-project.org/installation

symfonyのバージョンについて

現時点ではsymfony-1.0系と1.1系がstableとしてリリースされている。 1.0系は2010年1月までメンテナンスが保証されている。 1.1系は新たな機能を実装したバージョンで1.2系へのアップグレードが1.0系と比べて容易になっている。 1.2系への切り替えも視野に入れている場合は1.1系を利用すると良いだろう。 1.1系は2009年1月までメンテナンスされ、以降は1.2系に切り替わるようだ。

インストール環境

ここでは1.2系への乗り換えを見越して、1.1系のインストールを行ってみる。 作業をした環境は以下の通り

$ cat /etc/redhat-release
CentOS release 5.2 (Final)

yum install php.i386
yum install php-mbstring.i386
yum install php-xml.i386
yum install php-mysql.i386
yum install php-pear.noarch
yum install subversion.i386

pearコマンドを利用してインストールを行うので、pearパッケージは必須となる。

PropelなどのライブラリがXMLを扱うためいくつかの追加パッケージをインストールしている。

その他のインストール方法

pearコマンド以外でのインストール方法は本家のドキュメントを参照されたい。

http://www.symfony-project.org/installation/1_1

インストール手順

さっそくインストールを実行してみよう。

まず、pearがインストールされていることを確認する。

$ which pear
/usr/bin/pear

ということで、インストールされていることが確認できた。

pearコマンドを利用して、プロジェクトディレクトリ内にsymfonyをインストールする。プロジェクトを構成時にはサーバ環境に極力依存しないようにするために、ライブラリなどはすべてプロジェクトのディレクトリ内にインストールすると良い。

$ mkdir -p example/vendor
$ cd example/vendor

pearのconfig-createコマンドを利用して環境設定ファイルを作成する

$ pear config-create /path/to/example/vendor .pearrc
Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels   auto_discover  <not set>
Default Channel             default_channel pear.php.net
HTTP Proxy Server Address    http_proxy  <not set>
PEAR server [DEPRECATED]     master_server  <not set>
Default Channel Mirror       preferred_mirror <not set>
Remote Configuration File    remote_config  <not set>
PEAR executables directory   bin_dir         /path/to/example/vendor/pear
PEAR documentation directory doc_dir         /path/to/example/vendor/pear/docs
PHP extension directory     ext_dir      /path/to/example/vendor/pear/ext
PEAR directory               php_dir         /path/to/example/vendor/pear/php
PEAR Installer cache directory cache_dir        /path/to/example/vendor/pear/cache
PEAR data directory         data_dir         /path/to/example/vendor/pear/data
PHP CLI/CGI binary           php_bin         <not set>
PEAR test directory         test_dir         /path/to/example/vendor/pear/tests
Cache TimeToLive             cache_ttl      <not set>
Preferred Package State     preferred_state <not set>
Unix file mask               umask          <not set>
Debug Log Level             verbose      <not set>
PEAR password (for           password        <not set>
maintainers)
Signature Handling Program   sig_bin         <not set>
Signature Key Directory     sig_keydir   <not set>
Signature Key Id             sig_keyid      <not set>
Package Signature Type       sig_type        <not set>
PEAR username (for           username        <not set>
maintainers)
User Configuration File     Filename         /path/to/example/vendor/.pearrc
System Configuration File    Filename        #no#system#config#
Successfully created default configuration file "/path/to/example/vendor/.pearrc"

以降は、pearコマンドの-cオプションを利用してこの設定ファイルを利用するようにする

pearコマンドを使ってsymfonyのpearチャンネルを登録し、バージョンを指定してインストールを行う

$ pear -c .pearrc channel-discover pear.symfony-project.com
Adding Channel "pear.symfony-project.com" succeeded
Discovery of channel "pear.symfony-project.com" succeeded

$ pear -c .pearrc install -a symfony/symfony-1.1.1
downloading symfony-1.1.1.tgz ...
Starting to download symfony-1.1.1.tgz (2,131,490 bytes)
..............done: 2,131,490 bytes
install ok: channel://pear.symfony-project.com/symfony-1.1.1

vendorディレクトリから、プロジェクトルートディレクトリに戻り、インストールしたsymfonyパッケージからプロジェクトの初期化を行う

$ cd ..
$ vendor/pear/symfony generate:project example
>> dir+  /path/to/example/lib
>> dir+  /path/to/example/doc
>> dir+  /path/to/example/data
>> file+     /path/to/example/symfony
>> dir+  /path/to/example/web
>> dir+  /path/to/example/web/js
>> dir+  /path/to/example/web/css
>> file+     /path/to/example/web/css/main.css
>> dir+  /path/to/example/web/uploads
>> dir+  /path/to/example/web/uploads/assets
>> file+     /path/to/example/web/robots.txt
>> file+     /path/to/example/web/.htaccess
>> dir+  /path/to/example/web/images
>> dir+  /path/to/example/log
>> dir+  /path/to/example/apps
>> dir+  /path/to/example/test
>> dir+  /path/to/example/test/functional
>> dir+  /path/to/example/test/bootstrap
>> file+     /path/to/example/test/bootstrap/unit.php
>> file+     /path/to/example/test/bootstrap/functional.php
>> dir+  /path/to/example/test/unit
>> dir+  /path/to/example/config
>> file+     /path/to/example/config/databases.yml
>> file+     /path/to/example/config/rsync_exclude.txt
>> file+     /path/to/example/config/schema.yml
>> file+     /path/to/example/config/propel.ini
>> file+     /path/to/example/co.../ProjectConfiguration.class.php
>> file+     /path/to/example/config/properties.ini
>> dir+  /path/to/example/cache
>> dir+  /path/to/example/plugins
>> tokens   /path/to/example/config/propel.ini
>> tokens   /path/to/example/config/properties.ini
>> tokens   /path/to/example/co.../ProjectConfiguration.class.php
>> chmod 777 /path/to/example/cache
>> chmod 777 /path/to/example/log
>> chmod 777 /path/to/example/web/uploads
>> chmod 777 /path/to/example/symfony
>> chmod 777 /path/to/example/web/uploads/assets

これで、symfonyのプロジェクトが初期化されたので、svnを使ってソースをインポートする。

$ svn import https://svn.example.com/example/trunk .

以上でインストールは完了である。次回はsymfonyを使った簡単なアプリケーションを作成してみたい。