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.

  1. <?php
  2. use Phalcon\Mvc\Application;
  3. class MyApp extends Application
  4. {
  5. /**
  6. * Register the services here to make them general or register
  7. * in the ModuleDefinition to make them module-specific
  8. */
  9. protected function registerServices()
  10. {
  11. }
  12. /**
  13. * This method registers all the modules in the application
  14. */
  15. public function main()
  16. {
  17. $this->registerModules(
  18. [
  19. "frontend" => [
  20. "className" => "Multiple\\Frontend\\Module",
  21. "path" => "../apps/frontend/Module.php",
  22. ],
  23. "backend" => [
  24. "className" => "Multiple\\Backend\\Module",
  25. "path" => "../apps/backend/Module.php",
  26. ],
  27. ]
  28. );
  29. }
  30. }
  31. $application = new MyApp();
  32. $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

  1. <?php
  2. $this->registerModules(
  3. [
  4. "frontend" => [
  5. "className" => "Multiple\\Frontend\\Module",
  6. "path" => "../apps/frontend/Module.php",
  7. ],
  8. "backend" => [
  9. "className" => "Multiple\\Backend\\Module",
  10. "path" => "../apps/backend/Module.php",
  11. ],
  12. ]
  13. );

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