This repository serves as a base model for PHP projects, implementing the MVC pattern, Routes system, Middlewares and Componentization in the Controller and View layers. It also includes several utility tools to speed up development.
mvc_template/
βββ app
β βββ Classes
β β βββ Utils
β β βββ ApiResponse.php
β β βββ ArrayUtils.php
β β βββ CrudUtils.php
β β βββ FileUploader.php
β β βββ Formatting.php
β β βββ Math.php
β β βββ Url.php
β β βββ UUID.php
β β βββ View.php
β βββ config.php
β βββ Core
β βββ Controller
β β βββ Components
β β β βββ BaseStructure.php
β β β βββ Link.php
β β β βββ Links.php
β β β βββ Script.php
β β β βββ Scripts.php
β β βββ Middlewares
β β βββ Pages
β β βββ Home.php
β βββ Model
β β βββ Databases
β β β βββ SQL.php
β βββ View
β βββ Components
β β βββ BaseStructure
β β βββ Link
β β βββ Option
β β βββ Script
β βββ Pages
β βββ Home
β βββ index.html
βββ assets
β βββ css
β β βββ global.css
β β βββ home.css
β βββ img
β βββ logo.jpg
βββ index.php
βββ composer.json
βββ .env.example
βββ README.md
Conceito | Descrição |
---|---|
MVC | Modular organization between logic (Model), control (Controller) and visualization (View). |
Routes | Configured in app/Core/Routers.php , they allow you to associate URLs with controller methods. |
Middlewares | Manage checks before executing routes. |
Componentization | Reuse of visual and logical elements, such as Links and Scripts. |
Utilities | Classes for manipulating arrays, uploading files, generating UUIDs, and more. |
- Clone this repository:
git clone https://github.com/3nderXP/mvc_template.git
- Install the dependencies:
composer install
- Configure the environment:
Change necessary variables, such as database credentials, roots and the like.
Routes: Configure routes in the file app/Core/Routers.php
:
$router->get('/home', [HomeController::class, 'index']);
Controllers: Create Controllers in `app/Core/Controller/Pages/`` and implement methods associated with routes.
Views: Create HTML files in app/Core/View/Pages/
and render in the controllers:
return View::render('Pages/Home', ['data' => $value]);
- PHP >= 8.0
- Composer
This project is licensed under the MIT License. See the LICENSE file for more information.
Contributions are welcome! Open issues or send pull requests with improvements and suggestions.