NoobFramework is an MVC framework designed specifically for beginners. It serves as an educational tool for those learning the MVC design pattern in PHP.
MVC stands for Model-View-Controller, which is a widely-used software design pattern. Its fundamental concept involves dividing an application into three interconnected components:
- Model: Responsible for handling data manipulation, including reading, writing, and validation.
- View: Represents the user interface layer, responsible solely for presenting data to the user.
- Controller: Acts as an intermediary between the user and the application's logic. It receives user input, determines which model to interact with, and selects the appropriate view to render. Controllers contain methods known as actions.
Clone or download this repository and install dependencies:
composer install
Choose one of the following options (Built-in server or Docker), to run the project.
If you prefer to use PHP's built-in server for local development, navigate to the root of the project and run:
php -S localhost:8000
For Docker users, a Dockerfile is provided at the root of the project with the necessary configurations to run the framework. To use Docker:
- Build the Docker image:
docker build -t noobframework .
- Run the Docker container:
docker run -d --name noobframework -p 80:80 -v $(pwd):/var/www/html noobframework
- Develop your application within the
app
folder. This folder is organized into Controllers, Models, and Views. - The public folder serves as the document root for your application.
- Generate a
.env
file based on.env.example
(copy, paste and rename it), then configure your application settings within it. - Define your routes in the
route/router.php
file. Routing follows the features of nikic/fast-route. - To create a controller, add a new file inside
app/Controller
, similar to existing controllers (e.g., indexController.php). Similarly, add your models inside the Models folder and create views following the examples provided in the views folder. - Each controller can contain multiple actions (methods) corresponding to different user interactions.
For more, see documentation.