index.php
file in your App's public directory is executed. This is the entry point for all requests to your Cherrycake application, and all it does is loading Cherrycake, initialize it and call the Engine::attendWebRequest method. This looks something like this:baseCoreModules
. Since the Actions modules is the one in charge of receiving and handling requests, you should at least specify this module on the list.The default value for thebaseCoreModules
key is["Actions"]
, so if you only need the Actions module like in our example, you can skip this key on the hash array and it will be included automatically. In the example, this means we can simplify the Engine::init line to just$e->init(__NAMESPACE__)
To optimize performance, the method Engine::callMethodOnAllModules caches the information about which methods are available in modules so it doesn't need to search for those methods each time a request is made.
mapActions
methods found in any of the available modules (both core and app modules) are executed, so any module that needs to map an action to respond to requests must do it so on its mapActions
static method by calling the Actions::mapAction method. In our Home example module, this would look like this:index.php
asks the Actions module to find and run the action that matches the current request URI. This is how this request to the Actions module looks internally:Notice that this action matches our example request of the home page (/
path) because it specifically has nopathComponents
moduleName
and methodName
keys are used to specify which module::method should be called when the action is executed. In our example, Home::homePage.Cherrycake provides a request-level cache. At this point, if the requested Action has been cached, the result is obtained from cache and the execution ends here.
dependentCoreModules
property of Home, like this:end
method on all loaded modules. The Output calls Output::sendResponse on its end
method, causing the parsed HTML file to be sent to the browser and concluding the request lifecycle.