Skip to content

Class Phalcon\Mvc\Application

extends abstract class Phalcon\Application

implements Phalcon\Di\InjectionAwareInterface, Phalcon\Events\EventsAwareInterface

Source on GitHub

This component encapsulates all the complex operations behind instantiating every component needed and integrating it with the rest to allow the MVC pattern to operate as desired.

<?php

use Phalcon\Mvc\Application;

class MyApp extends Application
{
    /**
     * Register the services here to make them general or register
     * in the ModuleDefinition to make them module-specific
     */
    protected function registerServices()
    {

    }

    /**
     * This method registers all the modules in the application
     */
    public function main()
    {
        $this->registerModules(
            [
                "frontend" => [
                    "className" => "Multiple\Frontend\Module",
                    "path"      => "../apps/frontend/Module.php",
                ],
                "backend" => [
                    "className" => "Multiple\Backend\Module",
                    "path"      => "../apps/backend/Module.php",
                ],
            ]
        );
    }
}

$application = new MyApp();

$application->main();

Methods

public useImplicitView (mixed $implicitView)

By default. The view is implicitly buffering all the output You can full disable the view component using this method

public handle ([mixed $uri])

Handles a MVC request

public __construct ([Phalcon\DiInterface $dependencyInjector]) inherited from Phalcon\Application

Phalcon\Application

public setEventsManager (Phalcon\Events\ManagerInterface $eventsManager) inherited from Phalcon\Application

Sets the events manager

public getEventsManager () inherited from Phalcon\Application

Returns the internal event manager

public registerModules (array $modules, [mixed $merge]) inherited from Phalcon\Application

Register an array of modules present in the application

<?php

$this->registerModules(
    [
        "frontend" => [
            "className" => "Multiple\Frontend\Module",
            "path"      => "../apps/frontend/Module.php",
        ],
        "backend" => [
            "className" => "Multiple\Backend\Module",
            "path"      => "../apps/backend/Module.php",
        ],
    ]
);

public getModules () inherited from Phalcon\Application

Return the modules registered in the application

public getModule (mixed $name) inherited from Phalcon\Application

Gets the module definition registered in the application via module name

public setDefaultModule (mixed $defaultModule) inherited from Phalcon\Application

Sets the module name to be used if the router doesn't return a valid module

public getDefaultModule () inherited from Phalcon\Application

Returns the default module name

public setDI (Phalcon\DiInterface $dependencyInjector) inherited from Phalcon\Di\Injectable

Sets the dependency injector

public getDI () inherited from Phalcon\Di\Injectable

Returns the internal dependency injector

public __get (mixed $propertyName) inherited from Phalcon\Di\Injectable

Magic method __get


Class Phalcon\Mvc\Application\Exception

extends class Phalcon\Application\Exception

implements Throwable

Source on GitHub

Methods

final private Exception __clone () inherited from Exception

Clone the exception

public __construct ([mixed $message], [mixed $code], [mixed $previous]) inherited from Exception

Exception constructor

public __wakeup () inherited from Exception

...

final public string getMessage () inherited from Exception

Gets the Exception message

final public int getCode () inherited from Exception

Gets the Exception code

final public string getFile () inherited from Exception

Gets the file in which the exception occurred

final public int getLine () inherited from Exception

Gets the line in which the exception occurred

final public array getTrace () inherited from Exception

Gets the stack trace

final public Exception getPrevious () inherited from Exception

Returns previous Exception

final public Exception getTraceAsString () inherited from Exception

Gets the stack trace as a string

public string __toString () inherited from Exception

String representation of the exception