CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Namespace Controller

Namespaces

  • Cake\Controller\Attribute
  • Cake\Controller\Component
  • Cake\Controller\Exception

Classes

  • Component

    Base class for an individual Component. Components provide reusable bits of controller logic that can be composed into a controller. Components also provide request life-cycle callbacks for injecting logic at specific points.

    Initialize hook

    Like Controller and Table, this class has an initialize() hook that you can use to add custom 'constructor' logic. It is important to remember that each request (and sub-request) will only make one instance of any given component.

    Life cycle callbacks

    Components can provide several callbacks that are fired at various stages of the request cycle. The available callbacks are:

    • beforeFilter(EventInterface $event) Called before Controller::beforeFilter() method by default.
    • startup(EventInterface $event) Called after Controller::beforeFilter() method, and before the controller action is called.
    • beforeRender(EventInterface $event) Called before Controller::beforeRender(), and before the view class is loaded.
    • afterFilter(EventInterface $event) Called after the action is complete and the view has been rendered but before Controller::afterFilter().
    • beforeRedirect(EventInterface $event, $url, Response $response) Called before a redirect is done. Allows you to change the URL that will be redirected to by returning a Response instance with new URL set using Response::location(). Redirection can be prevented by stopping the event propagation.

    While the controller is not an explicit argument for the callback methods it is the subject of each event and can be fetched using EventInterface::getSubject().

  • ComponentRegistry

    ComponentRegistry is a registry for loaded components

    Handles loading, constructing and binding events for component class objects.

  • Controller

    Application controller class for organization of business logic. Provides basic functionality, such as rendering views inside layouts, automatic model availability, redirection, callbacks, and more.

    Controllers should provide a number of 'action' methods. These are public methods on a controller that are not inherited from Controller. Each action serves as an endpoint for performing a specific action on a resource or collection of resources. For example adding or editing a new object, or listing a set of objects.

    You can access request parameters, using $this->getRequest(). The request object contains all the POST, GET and FILES that were part of the request.

    After performing the required action, controllers are responsible for creating a response. This usually takes the form of a generated View, or possibly a redirection to another URL. In either case $this->getResponse() allows you to manipulate all aspects of the response.

    Controllers are created based on request parameters and routing. By default controllers and actions use conventional names. For example /posts/index maps to PostsController::index(). You can re-map URLs using Router::connect() or RouteBuilder::connect().

    Life cycle callbacks

    CakePHP fires a number of life cycle callbacks during each request. By implementing a method you can receive the related events. The available callbacks are:

    • beforeFilter(EventInterface $event) Called before each action. This is a good place to do general logic that applies to all actions.
    • beforeRender(EventInterface $event) Called before the view is rendered.
    • beforeRedirect(EventInterface $event, $url, Response $response) Called before a redirect is done.
    • afterFilter(EventInterface $event) Called after each action is complete and after the view is rendered.
  • ControllerFactory

    Factory method for building controllers for request.

  • ErrorController

    Error Handling Controller

    Controller used by ErrorHandler to render error views.

OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs