Actions guide

Actions is the routing core module of Cherrycake, and allows your application to receive requests and attend them accordingly.

When using Actions, all the modules who will be receiving requests should map their actions in the Module::mapActions method, by calling Actions::mapAction.

Actions is the default base core module because it is what you'll need in most cases. If you're experimenting with different ways of using Cherrycake, you can specify a different set of base modules in Engine::init

When a request is received, Actions will look through all the mapped actions. If any of them matches the current request, it will load the associated module and run the mapped method.

Actions calls mapActions methods on all available modules during its initialization, using the Engine::callMethodOnAllModules

For example, the following module maps a simple action named home that will call the viewHome method when the root page / is requested:

namespace CherrycakeApp\Modules;
class Home extends \Cherrycake\Module {
public static function mapActions() {
global $e;
new \Cherrycake\ActionHtml([
"moduleType" => \Cherrycake\ACTION_MODULE_TYPE_APP,
"moduleName" => "Home",
"methodName" => "viewHome",
"request" => new \Cherrycake\Request([
"pathComponents" => false
function viewHome() {
// Show the home page