以前、Composer で CakePHP をインストールいたしました。
その時の CakePHP のバージョンは「2.4.2」でございました。調べてみますと、Composer を使用すればアップデートできそうですのでやってみます♪
簡単にアップデートできました♪
Composer をセットアップした /var/www/html/cake/sample へと移動します。ここに、composer.json ファイルを作成したのでした。
この場所で、コマンド「php composer.phar update」を実行いたします。
[root@localhost sample]# php composer.phar update
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "composer.phar self-update" to get the latest version.
Loading composer repositories with package information
Initializing PEAR repository http://pear.cakephp.org
Updating dependencies (including require-dev)
- Removing pear-pear.cakephp.org/cakephp (2.4.2)
- Installing pear-pear.cakephp.org/cakephp (2.5.2)
Downloading: 100%
Skipped installation of bin/cake for package pear-pear.cakephp.org/cakephp: name conflicts with an existing file
Skipped installation of bin/cake.bat for package pear-pear.cakephp.org/cakephp: name conflicts with an existing file
Skipped installation of bin/cake.php for package pear-pear.cakephp.org/cakephp: name conflicts with an existing file
Writing lock file
Generating autoload files
[root@localhost sample]#
これで完了でした!とても簡単です。Vendor/pear-pear.cakephp.org/CakePHP/Cake/VERSION.txt ファイルを見てみましても、「2.5.2」とバージョンが上がっています。
また、composer.lock ファイルが更新され、アップデート後のバージョンが書き込まれています。
上手くアップデートされない時は、多分ここがポイント
実際に確かめたわけではございませんが、おそらくアップデートされない時は、composer.json ファイルの require 部分がポイントとなると存じます。
[root@localhost sample]# cat composer.json
{
"name": "example-app",
"repositories": [
{
"type": "pear",
"url": "http://pear.cakephp.org"
}
],
"require": {
"pear-cakephp/cakephp": ">=2.3.4"
},
"config": {
"vendor-dir": "Vendor/"
}
}
[root@localhost sample]#
>=2.3.4 と指定しております。これは、バージョン 2.3.4 以上の CakePHP をインストールする、という意味のようです。
もしこれが、<2.3.4 などと設定されておりますと、おそらくアップデートはされませんわね。
おわりに
Composer のアップデートの公式ドキュメントはこちらです。
また、次のページも参考になりました。アップデートとの関わりが書かれております。
以上です。

