Page cover image

PHPFast Overview

Framework Struct Overview

First, you need to get an overview of the structure of the Framework's parts:

Application Structure

Models, Views and Controllers

Libraries Overview

Helpers Overview

Command-Line (CLI)

Framework Document Overview

PHPFast is a lightweight and efficient PHP framework designed to optimize the web application development process. Below is a detailed guide on how to use the main components of PHPFast:

  • Core refers to the essential components of the framework, including classes for request handling, routing, application initialization, and other necessary components for the application to function.

  • The core is automatically initialized when you run your PHPFast application. You don’t need to intervene in the core framework unless you want to extend or modify how the framework operates. PHPFast will handle all user requests, perform routing, and call the appropriate controller to handle the request.

  • Routing in PHPFast maps URLs to specific controller methods. This allows you to define paths and methods to handle requests for each URL.

  • To define a route, you will use the Route class. Each route will have a specific path, an HTTP method (GET, POST, etc.), and the controller method that will handle the request. Routes can be grouped by modules or features of the application.

  • Controllers are responsible for handling user requests, performing necessary operations, and returning results, which can be either a view or a JSON response.

  • Controllers are defined as PHP classes, and each method within a controller handles a specific request. The methods in controllers can interact with models to fetch data, process business logic, and return results.

  • Models represent the data layer of the application and perform operations on the database.

  • Models are used to interact with the database and perform actions like querying, inserting, updating, or deleting data. A model typically represents a table in the database, and methods in the model perform the corresponding operations.

  • Views are responsible for rendering the user interface of the application, while Templates are dynamic HTML layouts used for reusing parts of the UI.

  • Views can be loaded and rendered with dynamic data, allowing information from the controller to be displayed to the user. Templates help separate logic and interface, making maintenance and changes to the UI easier.

  • The BaseBlock class is an abstract class in the PHPFast framework designed to manage the blocks within an application. It provides a structure for defining blocks, storing their associated data, and rendering their content.

  • This class serves as a foundation for creating customizable blocks in the application, ensuring consistency and reusability.

  • Middleware are intermediary classes that allow you to intervene in the request and response chain before they are processed by the controller or after the controller returns a response.

  • Middleware is commonly used for tasks such as user authentication, access control, logging, or validating input before further processing. Middleware can be applied to a specific route or to the entire application.

  • Helpers are utility functions that simplify common programming tasks such as working with strings, arrays, and validating data.

  • PHPFast provides several built-in helpers to support tasks like generating URLs, processing strings, or handling forms. You can call these helper functions directly from anywhere in the application without needing to instantiate additional objects.

  • Libraries provide additional functionality such as logging, session management, or handling external requests like emails, SMS, etc.

  • You can use the framework's libraries to access and utilize complex features without having to write custom code. These libraries can be loaded and used in controllers or models to handle specific tasks.

  • Description: Drivers provide specialized services such as database connections, email sending, or caching. Drivers help integrate external services into your application.

  • Usage: Drivers can be loaded and used to perform specific tasks, such as connecting to a database or managing cache. Each driver corresponds to a specific service and helps you perform related operations.

  • Commands allow you to perform tasks from the command line (CLI) such as database migrations, clearing cache, or running background jobs.

  • To create custom commands, you will define a new command class, extending the Command class. These commands can then be run from the command line to perform tasks automatically without needing to intervene in the source code.

Last updated

Was this helpful?