This project is a simple MVC (Model-View-Controller) framework written in PHP. It is designed for developers who want to build web applications with a clear separation of concerns. The framework provides a structured way to manage your code, making it easier to maintain and scale. It is suitable for both beginners and experienced developers looking for a lightweight and easy-to-use framework.
- Clone the repository:
git clone https://github.com/mojtabagh0098/simple-mvc-framework.git
- Navigate to the project directory:
cd simple-mvc-framework
- Install dependencies:
npm install
To use this project, follow these steps:
-
Start the development server:
php -S localhost:8000
-
Open your web browser and navigate to:
http://localhost:8000
-
You should see the default homepage of the MVC framework.
To create a new controller, follow these steps:
-
Create a new PHP file in the
controllers
directory, for exampleExampleController.php
:<?php class ExampleController { public function index() { echo 'Hello, world!'; } }
-
Define a route for your new controller in the
routes.php
file:$router->addRoute('/example', 'ExampleController::class','index');
-
Navigate to
http://localhost:8000/example
in your web browser to see the output.
This is a basic example to get you started. You can create more complex controllers, models, and views as needed.
We invite everyone to contribute and improve this MVC framework. Your contributions are valuable and will help make this project better for the community.
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch
- Make your changes and commit them:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature-branch
- Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.