https://github.com/adnane-ka/mini-mvc
a lightweight MVC-based PHP micro framework Inspired by Laravel.
https://github.com/adnane-ka/mini-mvc
Last synced: 3 months ago
JSON representation
a lightweight MVC-based PHP micro framework Inspired by Laravel.
- Host: GitHub
- URL: https://github.com/adnane-ka/mini-mvc
- Owner: adnane-ka
- License: mit
- Created: 2024-07-06T17:50:11.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-09T19:39:20.000Z (11 months ago)
- Last Synced: 2025-01-06T18:16:19.796Z (5 months ago)
- Language: PHP
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MINI MVC
This project was designed to build lightweight PHP applications based on the MVC architecture. It was inspired by Laravel to streamline development & provide easy use.
For a better saying, it's the lumen version for the lumen micro-framework.
## Installation
1. Download or clone the repository.
2. Run `composer install`.
3. Run `touch .env` to create an env file.
4. Copy `.env.example` content to `.env`.
6. Inject your mysql database credentials in `.env` file.
7. Run `php run db:migrate` for database migration.
8. Run `php run dev` to preview the project on your local webserver.## How to Use
If you intend to use this micro framework for a personal project, you can ignore the `core` directory unless you need to override existing functionality. All your application files should reside in the `app` directory, as you can use `routes.php` for route definition.
If you wish to contribute to this project, you are welcome to enhance or override the existing functionality in the `core` directory.
## View managment
For view rendering, we've choosed [Twig](https://twig.symfony.com/) as a default template engine.
## Project Structure
This project is organized into three primary components:
- **Models**: Located at [app/models](app/models)
- **Views**: Located at [app/views](app/views)
- **Controllers**: Located at [app/controllers](app/controllers)## Core Components
The foundational components of this project include:
- **Base Controller Class**: [core/BaseController.php](core/BaseController.php)
- **Database Connection Handler Class**: [core/Database/DBConnection.php](core/Database/DBConnection.php)
- **Query Builder Class**: [core/Database/QueryBuilder.php](core/Database/QueryBuilder.php)
- **Base Model Class**: [core/Database/BaseModel.php](core/Database/BaseModel.php)
- **Command Handler Class**: [core/CommandHandler.php](core/CommandHandler.php)
- **Router Handler Class**: [core/Facades/Router.php](core/Facades/Router.php)
- **Request Handler Class**: [core/Facades/Request.php](core/Facades/Request.php)
- **View Handler Class**: [core/Facades/View.php](core/Facades/View.php)
- **A set of helper functions**: [core/helpers.php](core/helpers.php)## Implementation Overview
1. All requests are routed through [index.php](index.php) as specified by the [.htaccess](.htaccess) file.
2. The router handler class includes the target controller and invokes the corresponding method as defined in [routes.php](routes.php).
3. The target controller interacts with models, leveraging the [BaseModel](core/BaseModel.php) class which utilizes a Query Builder to facilitate database interactions following an object-oriented paradiagm.
4. The target controller renders the appropriate view.## Future Enhancements
- Additional ORM implementations and Query Builder methods
- More utility/helper methods
- An exception handler for improved error handling
- Sanitization & data validating
- And much more ..We welcome and actively encourage contributions to this project. Whether you want to report bugs, suggest new features, or improve the existing code, your input is valuable. Join us in making this project better by submitting pull requests, participating in discussions, and sharing your expertise.