HMVC (Hierarchical Model-View-Controller): FuelPHP extends the traditional MVC pattern to HMVC, promoting modularity and reusability of code.
ORM (Object-Relational Mapper): Provides an ActiveRecord implementation for easy database interaction.
A quick reference guide for FuelPHP, a simple, flexible, community driven PHP 5.3+ framework, based on best practices and loaded with powerful features.
HMVC (Hierarchical Model-View-Controller): FuelPHP extends the traditional MVC pattern to HMVC, promoting modularity and reusability of code. ORM (Object-Relational Mapper): Provides an ActiveRecord implementation for easy database interaction. |
Security: Built-in CSRF protection, input filtering, and output encoding to prevent common web vulnerabilities. Bundles: Reusable packages of code that can be easily integrated into FuelPHP applications. |
Modules: Self-contained applications within a FuelPHP project, enabling code organization and separation of concerns. |
|
Main application configuration file. Located in |
|
Defines URL routes. Located in |
|
Database connection settings. Located in |
|
Specifies classes and packages to automatically load. Located in |
FuelPHP supports environment-specific configurations (development, production, testing).
|
Controllers handle user requests and interact with models to retrieve or modify data. |
Example:
|
Models represent data and provide methods for interacting with the database. |
Example:
|
Views are responsible for rendering data provided by controllers into HTML or other formats. |
Example (
|
Use |
Routes define how URLs are mapped to controllers and actions. Defined in |
Example:
|
You can use named parameters in your routes.
|
|
Returns the base URL of the application. |
|
Returns the current URI. |
|
Returns the nth segment of the URI. |
FuelPHP’s ORM simplifies database interactions. |
Example (Retrieving Data):
|
Example (Creating Data):
|
FuelPHP supports various relationship types (one-to-one, one-to-many, many-to-many). |
Example (One-to-Many in Model_User):
|
Now you can access the user’s posts:
|
For more complex queries, you can use the Query Builder. |
Example:
|