/vendordirectory in your project, and will install there the Cherrycake engine and all its dependencies.
If you want to use a namespace other than
CherrycakeAppfor your App, modify the snippet above to match it.
/public. Create this subdirectory now.
/path_to_your_app/publicin your virtual host configuration file and create the file
/public/.htaccessin your project with the following contents:
/public/index.phpfile will receive all the requests to your app and will be in charge of starting up the Cherrycake engine. Create it now and let's go step by step:
CherrycakeAppnamespace. In any case, we declare the namespace first:
$evariable as a convention:
Note that the entire Cherrycake engine lives inside the
Cherrycakenamespace, while your application lives in its own different namespace you declared above. Every time you'll refer to a Cherrycake class, module or constant you'll need to prefix it with the appropriate
\Cherrycake\namespace like we did here, or add a
usestatement at the top of your code. You'll see examples of that in the guide section and the provided examples.
appNameThe name of the application. You can skip this and one will be generated automatically.
isDevelWhen set to true, the application works in development mode, meaning you'll get extended error reports and other tricks to help you develop your app. When not specified, this parameter defaults to
baseCoreModules, it will be loaded immediately and, as part of the loading process, it will be initialized by calling the Actions::init method. What this method does in the Actions module, among other things, is to go through all available modules in both the Cherrycake engine and your app, check if they have a method called
mapActionsand run it.
It's as if the Actions module asked all other modules: "If you have any actions you would like to map to respond to requests, please let me know now!"
Note that there's actually no need to specify a
baseCoreModulessetup key when initializing the engine. If you skip this parameter, the Actions module will be loaded by default, which is the most common scenario when developing regular apps.
endmethods of all the loaded modules, so they can perform any cleaning tasks like disconnecting from external sources:
index.phpfile ends looking like this:
/route of your web application and respond by showing a simple HTML "Hello world" message.
/src/HelloWorld/HelloWorld.class.phpand edit it so it declares an empty module structure, like this:
Remember to use the same namespace you choose for your application in the
Also, don't forget that modules have their own directory inside
/src, that directory name must match the module name, even with uppercase and lowercase characters.
/path (that's why
pathComponentshas been set to false), and will call the
showmethod on the
HelloWorldmodule (the same module we're working on). Take a look at the Actions guide to learn about how to map more advanced actions.
This seems to be a somewhat overkill way of doing what could've been done with a simple
echo "Hello world"line, isn't it?