Migration
Instructions on how to migrate your existing Cherrycake application from earlier versions of the Cherrycake engine.
Migrating from 1.x to 2.x
If you were using the Locale module to get multi-lingual texts in your App, take a look at the new Translation module.
Almost all the important methods are now called using named arguments, which allows for an easier and cleaner way of passing parameters to methods. The best way of migrating your app is to take a look at the updated documentation for each module and class you're using to see how parameters are now passed.
Migrating from 0.x to 1.x
Update your
composer.json
file to require Cherrycake version 1.x instead of version 0.x:Create the
src
directory in your project and move your modules there. Remember modules still have their own subdirectory undersrc
. You can remove the now emptyModules
directory.Move all your classes to the
src
directory. Remember classes do not have their own subdirectory, so they reside on the root ofsrc
. You can remove the now emptyClasses
directory.Rename all your modules and class files so they end with
.php
instead of.class.php
. For example:MyModule.php
instead ofMyModule.class.php
.Assign all your modules to their own namespace by modifying or adding a
namespace
directive at the top of the file. For example, if your module is calledMyModule
, you should add this at the top ofsrc/MyModule/MyModule.php
:Remember also to correctly namespace the class your modules extend from. For example, instead of your module being declared like this:
declare it like this instead:
Assign all your classes the right namespace. If they're classes related to a module, move them to the related module's directory and add the matching namespace. For example, if your class is called
ClassForMyModule
and is related to a module calledMyModule
, move it tosrc/MyModule
and add this at the top ofsrc/MyModule/ClassForMyModule.php
:You'll need to change how you reference Cherrycake's core modules and classes throughout your code. For example, the following code:
Should be changed to this:
Autoloading of classes is now handled via composer, so you need to add this to your
composer.json
file:Update composer's autoload by running the command:
See the documentation at cherrycake.io and the examples at documentation-examples.cherrycake.io/ to see examples using this new namespacing.
Last updated