Documentation

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

 class Application extends \Phalcon\Mvc\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(array(
                    'frontend' => array(
                            'className' => 'Multiple\Frontend\Module',
                            'path' => '../apps/frontend/Module.php'
                    ),
                    'backend' => array(
                            'className' => 'Multiple\Backend\Module',
                            'path' => '../apps/backend/Module.php'
                    )
            ));
    }
}

$application = new Application();
$application->main();

Methods

public __construct ([Phalcon\Di $dependencyInjector])

public Phalcon\Mvc\Application useImplicitView (boolean $implicitView)

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

public Phalcon\Mvc\Application autoSendHeader (boolean $autoSendHeader)

Enable or disable sending cookies by each request

public Phalcon\Http\ResponseInterface handle ([unknown $data])

Handles a MVC request

public mixed request (unknown $uri, [array $data], [Phalcon\DiInterface $dependencyInjector])

Does a HMVC request in the application

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

Register an array of modules present in the application

<?php

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

public array getModules () inherited from Phalcon\Application

Return the modules registered in the application

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

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

public string 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 Phalcon\DiInterface getDI ([unknown $error], [unknown $notUseDefault]) inherited from Phalcon\Di\Injectable

Returns the internal dependency injector

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

Sets the event manager

public Phalcon\Events\ManagerInterface getEventsManager () inherited from Phalcon\Di\Injectable

Returns the internal event manager

public boolean fireEvent (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable

Fires an event, implicitly calls behaviors and listeners in the events manager are notified

public mixed fireEventCancel (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable

Fires an event, can stop the event by returning to the false

public boolean hasService (string $name) inherited from Phalcon\Di\Injectable

Check whether the DI contains a service by a name

public Phalcon\Di\ServiceInterface setService (unknown $name) inherited from Phalcon\Di\Injectable

Sets a service from the DI

public object|null getService (unknown $name) inherited from Phalcon\Di\Injectable

Obtains a service from the DI

public mixed getResolveService (string $name, [array $args], [unknown $noerror], [unknown $noshared]) inherited from Phalcon\Di\Injectable

Resolves the service based on its configuration

public attachEvent (string $eventType, Closure $callback) inherited from Phalcon\Di\Injectable

Attach a listener to the events

public __get (unknown $property) inherited from Phalcon\Di\Injectable

Magic method __get

public __sleep () inherited from Phalcon\Di\Injectable

...

public __debugInfo () inherited from Phalcon\Di\Injectable

...