MaplePHP
  • MaplePHP - Layered structure MVC PHP framework
  • Guide
    • Get started
    • Installation
    • Service Provider
    • Dependency injector
    • Controller
    • Middlewares
    • Routers
  • Navigation
    • Simple navigation
    • Dynamic navigation
  • Template engine
    • Getting started
    • Templates
      • Index
      • Views
      • Partials
    • Content (DTO)
      • String
      • Number
      • Array
      • DateTime
      • Encode
      • Dom
  • Form builder
    • Form builder
  • Database
    • MySQL
  • Service providers
    • url
    • encode
    • dir
    • DB
    • responder
  • Installations
    • Authorization & login
  • Frontend template
    • Responder
    • Views & components
    • Modals
    • Redirects
  • Access
    • MaplePHP with Docker
  • Libraries
    • Container
    • MySQL queries
    • Validation
    • Cache
    • Logger
    • Request
    • Response
  • What is?
    • Dependency injector
    • Controller
    • Middleware
    • Router
Powered by GitBook
On this page

Was this helpful?

  1. What is?

Controller

In PHP, a controller is responsible for handling user input, processing requests from the client, interacting with the model (data and business logic), and returning an appropriate response to the user via the view. Here's a brief overview of the responsibilities of a PHP controller:

  1. Receives User Input: The controller receives input from the user or client, typically through the request parameters, such as form submissions or URL parameters.

  2. Processes Requests: It processes the received input and makes decisions based on the application's business logic. This may involve interacting with the model (database or other data sources) to retrieve or manipulate data.

  3. Updates the Model: The controller communicates with the model to update data or retrieve information needed to fulfill the user's request.

  4. Returns a Response: Once the processing is complete, the controller is responsible for determining the appropriate response to send back to the user. This could be rendering a view, redirecting to another page, or sending JSON data in the case of an API.

PreviousDependency injectorNextMiddleware

Last updated 1 year ago

Was this helpful?