Category: Installation

Q: Upgrade CakePHP from 3.2 to 3.3

I have an application that was built by CakePHP 3.2. I'd like to upgrade to v3.3.

{
    "name": "cakephp/app",
    "description": "CakePHP skeleton app",
    "homepage": "http://cakephp.org",
    "type": "project",
    "license": "MIT",
    "require": {
        "php": ">=5.5.9",
        "cakephp/cakephp": "~3.2",
        "mobiledetect/mobiledetectlib": "2.*",
        "cakephp/migrations": "~1.0",
        "cakephp/plugin-installer": "*"
    },
    "require-dev": {
        "psy/psysh": "@stable",
        "cakephp/debug_kit": "~3.2",
        "cakephp/bake": "~1.1"
    },
    "suggest": {
        "phpunit/phpunit": "Allows automated tests to be run without system-wide install.",
        "cakephp/cakephp-codesniffer": "Allows to check the code against the coding standards used in CakePHP."
    },
    "autoload": {
        "psr-4": {
            "App\\": "src"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Test\\": "tests",
            "Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
        }
    },
    "scripts": {
        "post-install-cmd": "App\\Console\\Installer::postInstall",
        "post-create-project-cmd": "App\\Console\\Installer::postInstall",
        "post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump"
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}

But I don't feel safe to upgrade v3.3 via Composer's command.. Can someone show me the correct Composer command to upgrade CakePHP safely? Thank you.

SOLVED composer upgrade
3 Answers

Version: 3.2.1

user
Lara

4

In the macOS/linux terminal:

$ cd /{cake_application_path}
$ composer update

if your composer was installed globally, or 

$ php composer.phar update


Sit back and then composer will do the rest for you.

Accepted by Lara

If you want to update PHP dependencies via Composer: It's all about composer.lock. The point of composer.lock file is to record the exact versions that are installed. To run an application-wide upgrade, run:

composer update

or upgrade a specified dependency:

composer update {dependency name}

---

So, for example, from 3.0 to 3.3:

//composer.json - generated from initial installation.
"cakephp/cakephp": "~3.0",

//composer.lock - records the exact version.
{
  "name": "cakephp/cakephp",
  "version": "3.3.4"

Create a new Cakephp 3 project in new folder, and then paste dependencies manually to your original application folder.

1. Create new (latest) Cakephp 3 application via Composer

$ cd /your web root/
$ composer self-update
$ composer create-project prefer-dist cakephp/app tempcakephp

2. copy core libraries in /vendor/cakephp to your original application folder.

$ cp -a /tempcakephp/vendor/cakephp/. /your application/vendor/cakephp

and done!

redweb
redweb

2