Composerを利用してのFuelPHP初期セットアップ
頻繁にセットアップするわけじゃないので毎回忘れるし、
その時々で方法が変わってたりするので現時点でのFuelPHP
インストール手順をメモ。
■参考
FuelPHP 1.7.2のComposerによるインストール
http://blog.a-way-out.net/blog/2014/07/14/fuelphp-1-7-2-composer-installation/
$ composer create-project fuel/fuel:dev-1.7/master ProjectName
タイムアウトしてしまった。
Failed to download fuel/core from source: The process "git clone --no-checkout 'git://github.com/fuel/core.git' 'fuel/core' && cd 'fuel/core' && git remote add composer 'git://github.com/fuel/core.git' && git fetch composer" exceeded the timeout of 300 seconds.
タイムアウトの対策
Why composer install timeouts after 300 seconds?
http://stackoverflow.com/questions/18917768/why-composer-install-timeouts-after-300-seconds
$ export COMPOSER_PROCESS_TIMEOUT=600
一回消してもう一度行う。
$ composer create-project fuel/fuel:dev-1.7/master ProjectName Installing fuel/fuel (dev-1.7/master bafb42f2ab52968aea886ef1e6f341d8a62840c9) - Installing fuel/fuel (dev-1.7/master 1.7/master) Cloning 1.7/master Created project in ProjectName Loading composer repositories with package information Installing dependencies (including require-dev) - Installing composer/installers (v1.0.21) Loading from cache - Installing fuel/docs (dev-1.7/master 473174d) Cloning 473174da2cf503c60d4a9935b71acfc31f0906d0 - Installing fuel/core (dev-1.7/master e8c221a) Cloning e8c221af4cb685aefef20cc50a70f369eb37cb95 - Installing fuel/auth (dev-1.7/master aa9bd2e) Cloning aa9bd2e5104026814ff516aacf03258f62a94a55 - Installing fuel/email (dev-1.7/master 8fbf378) Cloning 8fbf378d74bac170a96cad96ba0aed77e319a865 - Installing fuel/oil (dev-1.7/master ea37c3a) Cloning ea37c3a7fe8675fb3327327213b2eca55303933a - Installing fuel/orm (dev-1.7/master 5e05c30) Cloning 5e05c3068562548657fea69850a23b23f65a5545 - Installing fuel/parser (dev-1.7/master 0cacd10) Cloning 0cacd10d7b1b8f92a0eeddce75c6ba2c0c28112f - Installing fuelphp/upload (2.0.2) Loading from cache - Installing psr/log (1.0.0) Loading from cache - Installing monolog/monolog (1.5.0) Loading from cache - Installing michelf/php-markdown (1.4.0) Loading from cache monolog/monolog suggests installing mlehner/gelf-php (Allow sending log messages to a GrayLog2 server) monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server) monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server) monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required)) monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server) Writing lock file Generating autoload files Made writable: /home/user/public_html/ProjectName/fuel/app/cache Made writable: /home/user/public_html/ProjectName/fuel/app/logs Made writable: /home/user/public_html/ProjectName/fuel/app/tmp Made writable: /home/user/public_html/ProjectName/fuel/app/config Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? Y $ cd ProjectName/ $ oil --version Fuel: 1.7.3 running in "development" mode
とりあえずインストールは出来た。
■git管理と権限設定
$ git init Initialized empty Git repository in /******/ProjectName/.git/ $ git add -A $ git commit $ oil refine install Made writable: /home/user/public_html/ProjectName/fuel/app/cache Made writable: /home/user/public_html/ProjectName/fuel/app/logs Made writable: /home/user/public_html/ProjectName/fuel/app/tmp Made writable: /home/user/public_html/ProjectName/fuel/app/config
■DIコンテナを入れておく
Fuel Dependency
https://github.com/fuelphp/dependency
$ vim composer.json $ composer update Loading composer repositories with package information Updating dependencies (including require-dev) - Installing fuelphp/dependency (2.0.0) Downloading: 100% Writing lock file Generating autoload files
■アクセスURLの変更
アクセスするURLを調整するためにpublicディレクトリを任意の場所に任意の名前でコピー
この時assetsディレクトはコピーしないでおく。
fuel/core/config/asset.php
を
fuel/app/config
にコピーし
'paths' => array('assets/'),
の箇所を変更する。
■index.phpを消す
$ vim fuel/app/config/config.php index_file' => false, .htaccessの以下の部分のコメントを外す # Remove index.php from URL #RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$ #RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC] #RewriteRule ^index\.php(.*)$ $1 [R=301,NS,L] ↓ # Remove index.php from URL RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$ RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC] RewriteRule ^index\.php(.*)$ $1 [R=301,NS,L]
これで駄目な場合は
RewriteBaseを指定してみる。
あとはnamespaceベースでの指定とかに変更したりする。