The Apprunner

The Apprunner is the core of Mamuph framework because it provides some basic features like the autoloader, initialization routines and some basic methods. Some useful methods provided by Apprunner are:

Apprunner::find_file

It finds a file and return their path.

Parameters

  • $dir (string): Directory name
  • $file (string): File name
  • $ext (string): File extension
  • $array (bool): When is equal to "true" the path is returned into an array wrapper. By default $array is equal to "false"

Returns

  • string or array

Example

    // Search the path of the version.php file
    Apprunner::find_file('version', 'config', 'php');

Apprunner::execute

Load and execute an action defined into a Controller. By default the "action_main" is called. This method it helps to call different controllers in an easy way.

Parameters

  • string: Controller name
  • string: Entry point method name (By default: action_main)
  • mixed: Parameters passed to the entry point method

Returns

  • mixed

Example

// It calls the method "action_main" from the file src/App/Controllers/Foo.php
Apprunner::execute('Foo');

// It calls the method "bar" from the file src/App/Controllers/Foo.php
Apprunner::execute('Foo', 'bar');

Apprunner::terminate

Terminate the program execution and return an exit code.

Parameters

Example

// Terminate the program return the success code (0)
Apprunner::terminate(Apprunner::EXIT_SUCCESS);

// Terminate the program and return the general failure code (1)
Apprunner::terminate(Apprunner::EXIT_FAILURE);

// Terminate the program and return the permission denied code (77)
Apprunner::terminate(Apprunner::EXIT_NOPERM);

// Terminate the program and return the custom exit code 33
Apprunner::terminate(33);