This project is a basic web application template in PHP following the Model-View-Controller (MVC) design pattern and extensively applying the Dependency Injection Pattern.
The MVC design pattern combined with dependency injection is an excellent combination in PHP projects. The Model-View-Controller pattern separates responsibilities between business logic (Model), user interface (View), and application flow control (Controller). Dependency injection helps avoid spaghetti code, improving code scalability and maintenance. Additionally, this project includes a service layer to handle business logic, similar to how projects are structured in Spring.
- User Authentication: User login, registration, and logout.
- User Profile: View details of the logged-in user.
- Basic Template: This project serves as a template with basic functionality for a web page.
- PDO Implementation: By default, the project includes an implementation to access the database using PDO (PHP Data Objects).
- CSRF Protection: Built-in protection against Cross-Site Request Forgery (CSRF) attacks.
.env.example
: Example configuration file for environment variables (.env)..gitignore
: Configuration file to ignore files in Git..htaccess
: Configuration file for URL rewriting in Apache.composer.json
: Composer file with dependencies and autoloads.index.php
: Main entry point of the application.src/
: Contains the application logic.Controllers/
: Application controllers.DependencyContainer.php
: Contains the dependency container.Dtos/
: Data Transfer Objects.Helpers/
: Helper functions.Models/
: Data models.Repositories/
: Repositories to interact with the database.RouteHandler.php
: Handles the application routing.Services/
: Application services.
views/
: Application views.
- PHP Version >= 8.1
- Composer Version >= 2.5.5
- MySQL/MariaDB
- Install the dependencies:
composer install
- Configure the environment variables in the
.env
file:PDO_DB_DSN= PDO_DB_USER= PDO_DB_PASSWORD=
- Set up the database: Execute the SQL Script to create the necessary tables.
- Start the local PHP server:
php -S localhost:8000
- ccess the application at
http://localhost:8000
Contributions are welcome. If you want to contribute, follow these steps:
- Fork the project.
- Create a new branch (name it descriptively e.g.,
feature/new-feature
). - Make changes and commit them.
- Submit a pull request.