Documentation

Table Of Contents

Previous topic

< Class Phalcon\Mvc\Collection\Manager

Next topic

Class Phalcon\Mvc\Dispatcher >

This Page

Abstract class Phalcon\Mvc\Controller

extends abstract class Phalcon\Di\Injectable

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

Source on GitHub

Every application controller should extend this class that encapsulates all the controller functionality

The controllers provide the “flow” between models and views. Controllers are responsible for processing the incoming requests from the web browser, interrogating the models for data, and passing that data on to the views for presentation.

<?php

<?php

class PeopleController extends \Phalcon\Mvc\Controller
{
    // This action will be executed by default
    public function indexAction()
    {

    }

    public function findAction()
    {

    }

    public function saveAction()
    {
        // Forwards flow to the index action
        return $this->dispatcher->forward(
            [
                "controller" => "people",
                "action"     => "index",
            ]
        );
    }
}

Methods

final public __construct ()

Phalcon\Mvc\Controller constructor

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 setEventsManager (Phalcon\Events\ManagerInterface $eventsManager) inherited from Phalcon\Di\Injectable

Sets the event manager

public getEventsManager () inherited from Phalcon\Di\Injectable

Returns the internal event manager

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

Magic method __get

Follow along: