CakePHP version 3.0 is coming closer and closer to a stable release.

The leap from PHP5.2 to PHP5.4 was more than necessary. Personally, I think, this will bring CakePHP back on the same level as "Laravel" or "Symfony2".

Those, using already PHP5.3 for a while, kind of left CakePHP behind. But now those will probably be overtaken again to some extend 😉

Try it out now.

All you need is to clone the cakephp/app repo, run composer update on it and its ready to go.

Alternatively, you can run this simple command:

composer create-project -s dev cakephp/app [app_name]

Major differences compared to 2.x:

All namespaces. Note that they live only in the respective file. So try to avoid non-helper class usage in your view layer. Better to wrap them as helpers.

The former APP dir is now src , and a subfolder of the root dir. The composer.json file stays in root, though. So does "vendor" (note the lowercase v), "plugins", "tests", "config" and "webroot". So basically, the src now only contains the classes, view templates and Locale .

, and a subfolder of the root dir. The composer.json file stays in root, though. So does "vendor" (note the lowercase v), "plugins", "tests", "config" and "webroot". So basically, the now only contains the classes, view templates and . Directly uses PHPUnit – there is no shell and no web test runner anymore (I do miss the latter though sometimes – VisualPHPUnit is supposed to substitute).

Completely new ORM – returning objects to easily work with.

Session is not static anymore. So using it inside models/behaviors is discouraged.

Themes are now Basic Plugins.

Uses templates for FormHelper and CO – making it way more customizable.

Upgrading

If you followed my earlier posts you probably know by now that I paid close attention to the changes between 2.x and 3.x.

So my 2.x code already follows the new standards as close as it gets. This sure eases a possible 3.x upgrade.

The most important ones are:

Use composer and git (no git submodules etc)

Use query strings (remove all named params)

Remove deprecated functionality and provide shims if necessary

For details on latest 2.x upgrades see this article.

So use the following weeks or months wisely, and already bring your application to a current up-to-date version. Especially if you plan on upgrading it to 3.x some time.

Taking away already most of the work beforehand and in small and well testable steps is the best approach.

Even if you don’t plan to upgrade the outlined standards sure ease current and future development. And that saves time and money.

I will soon release a new post with some experiences of upgrading small 2.x apps to 3.x. So stay tuned.

First Cake3.x notes and tips

I have been playing around with the dev, alpha and beta release so far, and I like it a lot so far. A lot 🙂

The migration guide looks intimidating for sure. But for new projects it will be irrelevant anyway.

I still would want to wait until at least a few important plugins are upgraded – so probably close to stable release.

How to overwrite static classes

This has been pretty much impossible to do without namespaces in 2.x so far.

Now you can overwrite/extend those classes very easily, as well. E.g. the Utility Hash class:

namespace App\Utility; use Cake\Utility\Hash as BaseHash; class Hash extends BaseHash { }

You can then use App\Utility\Hash throughout your code to get access to any additional methods you want to add/change.

No need for phpunit composer dependency anymore

Use the phpunit.phar file directly and you don’t need the dependency in Cake3.x. It is also easier to work with, just drop it in your root folder and run:

php phpunit.phar

It will automatically read the config from the phpunit.xml file in your application’s root folder.

Oh, and CakePHP get’s more and more popular:

Currently it’s the 3rd most popular PHP framework on GitHub (No, codeigniter doesn’t count). For some reason ZF2 isn’t shown here. If you then compare RAD from CakePHP with the other two remaining ones, there really is only one to pick, isn’t there? After all, development speed matters…