それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

Symfony1.2の環境に1.0を共存インストール

Symfony1.0のインストール

PEARコマンドでsymfony1.2系の最新版が入っている環境にsymfony1.0を入れて使う。
難しい処理は特にない。

必要なもの

あるといいもの。

進め方。

  • symfony1.0を保存するライブラリパスを作る。
  • Subversionで最新版を持ってくる。
  • mercurialでsymfony1.0の不意の変更を防ぐ
  • symfony1.0でプロジェクトを始める。

Symfony1.0を入れるディレクトリを作る

今回は、使うだけなのでWWW空間に入れることにする。

$>mkdir /var/www/symfony1.0
$>svn co http://svn.symfony-project.com/branches/1.0 symfony1.0
$>cd symfony1.0

symfonyフォルダのウッカリ編集を防ぐためにバージョニングを管理する

$>hg init
$>hg add
$>echo -e "\
syntax: glob \n\
*.pyc \n\
.svn \n\
*~ \n\
*.bak \n\
*.swp \n\
Thumbs.db \n\
.DS_Store \n\
cache/* \n\
log/* \n\
 \
"\
> .hgignore
$>hg ci -m "symfony1.0の最新版を本家サイトからチェックアウトした。"
$>hg tag -m "syfony1.0の最新版の最初" checkout_symfony1.0

hgの管理に入ったことを確認。

$>hg log
changeset:   1:0446f8b5d2d7
tag:         tip
user:        takuya@autena.jp
date:        Tue Feb 10 11:21:52 2009 +0900
summary:     syfony1.0の最新版の最初
changeset:   0:6b0f785c120b
tag:         checkout_symfony1.0
user:        takuya@autena.jp
date:        Tue Feb 10 11:21:52 2009 +0900
summary:     symfony1.0の最新版を本家サイトからチェックアウトした。

プロジェクトをsymfony1.0系で作る。

PHPのバージョンを確認

$>php -v
PHP 5.2.4-2ubuntu5.4 with Suhosin-Patch 0.9.6.2 (cli) (built: Nov 25 2008 22:10:31) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
既存のsymfonyを確認
$> which symfony
/usr/bin/symfony
$>symfony -V
symfony version 1.2.2 (/usr/share/php/symfony)

既存のものが1.2.2で存在する。既存のものを上書きしないように注意して作業を始める。

symfony1.0がキッチリ動くことを確認する。

$>cd /var/www/symfony1.0/data/bin
$>./symfony -V
symfony version 1.0.20-PRE
$>cd ~
$>/var/www/symfony1.0/data/bin/symfony 
available pake tasks:
  clear-cache                > clear cached information
  clear-controllers          > clear controllers
  disable                    > disables an application in a given environment
  downgrade                  > downgrade to a previous symfony release
  enable                     > enables an application in a given environment
  fix-perms                  > fix directories permissions
  freeze                     > freeze symfony libraries
  init-app                   > initialize a new symfony application
  init-batch                 > initialize a new symfony batch script
  init-controller            > initialize a new symfony controller script
  init-module                > initialize a new symfony module
  init-project               > initialize a new symfony project
  log-purge                  > purges an applications log files
  log-rotate                 > rotates an applications log files
  plugin-install             > install a new plugin
  plugin-list                > list installed plugins
  plugin-uninstall           > uninstall a plugin
  plugin-upgrade             > upgrade a plugin
  propel-build-all           > generate propel model and sql and initialize database
  propel-build-all-load      > generate propel model and sql and initialize database, and load data
  propel-build-db            > create database for current model
  propel-build-model         > create classes for current model
  propel-build-schema        > create a schema from existing database
  propel-build-sql           > create sql for current model
  propel-convert-xml-schema  > create schema.yml from schema.xml
  propel-convert-yml-schema  > create schema.xml from schema.yml
  propel-dump-data           > dump data to fixtures directory
  propel-generate-crud       > generate a new propel CRUD module
  propel-init-admin          > initialize a new propel admin module
  propel-init-crud           > initialize a new propel CRUD module
  propel-insert-sql          > insert sql for current model
  propel-load-data           > load data from fixtures directory
  sync                       > synchronise project with another machine
  test-all                   > launch all tests
  test-functional            > launch functional tests for an application
  test-unit                  > launch unit tests
  unfreeze                   > unfreeze symfony libraries
  upgrade                    > upgrade to a new symfony release
task aliases:
  app                        = pake init-app
  batch                      = pake init-batch
  cc                         = pake clear-cache
  controller                 = pake init-controller
  module                     = pake init-module
  new                        = pake init-project

キッチリ動来ますね。行けそうだ。

新しいプロジェクトフォルダを作る。

$>mkdir /var/www/test
$>cd /var/www/test
$>/var/www/symfony1.0/data/bin/symfony init-project test
>> dir+      /var/www/test/batch
>> dir+      /var/www/test/web
>> file+     /var/www/test/web/.htaccess
>> file+     /var/www/test/web/robots.txt
>> dir+      /var/www/test/web/images
>> dir+      /var/www/test/web/uploads
>> dir+      /var/www/test/web/uploads/assets
>> dir+      /var/www/test/web/css
>> file+     /var/www/test/web/css/main.css
>> dir+      /var/www/test/web/js
>> file+     /var/www/test/symfony
>> dir+      /var/www/test/lib
>> dir+      /var/www/test/lib/model
>> dir+      /var/www/test/plugins
>> dir+      /var/www/test/cache
>> dir+      /var/www/test/config
>> file+     /var/www/test/config/config.php
>> file+     /var/www/test/config/propel.ini
>> file+     /var/www/test/config/schema.yml
>> file+     /var/www/test/config/rsync_exclude.txt
>> file+     /var/www/test/config/properties.ini
>> file+     /var/www/test/config/databases.yml
>> dir+      /var/www/test/apps
>> dir+      /var/www/test/test
>> dir+      /var/www/test/test/unit
>> dir+      /var/www/test/test/bootstrap
>> file+     /var/www/test/test/bootstrap/functional.php
>> file+     /var/www/test/test/bootstrap/unit.php
>> dir+      /var/www/test/test/functional
>> dir+      /var/www/test/doc
>> dir+      /var/www/test/log
>> dir+      /var/www/test/data
>> dir+      /var/www/test/data/model
>> dir+      /var/www/test/data/sql
>> tokens    /var/www/test/config/propel.ini
>> tokens    /var/www/test/config/properties.ini
>> tokens    /var/www/test/config/propel.ini
>> tokens    /var/www/test/config/config.php
>> chmod 777 /var/www/test/cache
>> chmod 777 /var/www/test/log
>> chmod 777 /var/www/test/web/uploads
>> chmod 777 /var/www/test/symfony
>> chmod 777 web/uploads/assets
今後、このフォルダのsymfonyフォルダが1.0で動くことを確認する。
$> ./symfony -V
symfony version 1.0.20-PRE
$>cat config/config.php
<?php

// symfony directories
$sf_symfony_lib_dir  = '/var/www/symfony1.0/lib';
$sf_symfony_data_dir = '/var/www/symfony1.0/data';

うん。これで問題なく動きますね。