IRPHP is a simple, lightweight, and extensible MVC PHP framework designed for building modern PHP web applications with clean architecture.
- Clean MVC structure
- Simple and customizable routing system (with optional auto-routing)
- Powerful and fluent HTTP Response system
- View system with layout/extend support
.envfile support- PSR-4 autoloading (Composer ready)
project/
│── app/
│ ├── Controllers/
│ │ ├── IndexController.php
│ │ ├── .....php
│ ├── Models/
│ │ ├── User.php
│ │ ├── .....php
│ ├── Services/
│ │ ├── ....php
│── routes/
│ ├── web.php
│── public/
│ ├── index.php
│── bootstrap.php
│── .env
│── composer.json
-
Clone the repository:
git clone https://github.com/javadnasrollahi/irphp-framework.git cd irphp-framework -
Install dependencies via Composer:
composer install
-
Copy
.env.exampleto.envand configure your environment variables.
Run the built-in PHP server using:
php -S 127.0.0.1:8080 -t publicVisit http://127.0.0.1:8080 in your browser.
Define your routes in routes/webhook.php or other route files:
$router->get('/', 'IndexController@index');Supports:
- GET, POST, PUT, DELETE methods
- Optional auto-routing mode (configurable)
Example controller:
namespace App\Controllers;
use App\Core\Response;
class IndexController
{
public function index()
{
return Response::make()
->view('index', ['name' => 'Amir'])
->send();
}
}View file: app/Views/index.php
<?php \App\Core\View::extend('master'); ?>
<h1>Hello, <?= htmlspecialchars($name) ?> 👋</h1>Supports layout extending and data passing.
You can run the tests using PHPUnit. First, make sure you have PHPUnit installed via Composer:
composer install --devTo run the tests:
composer testThis will run the test suite and show the results.
Tests are located in the tests/ directory.
You can use the CLI tool to generate modules, controllers, and other components automatically.
To create a new module (e.g., category):
composer cli categoryThis will generate:
- Controller files:
items.php,item.php,create.php,update.php,delete.php - Model file
- Routes file
This helps speed up the development process by generating boilerplate code for you.
- Middleware support
- CLI command runner
- Unit testing structure
- Database migrations
- Dependency injection container
- REST API utilities
Contributions are welcome! Feel free to fork the repo and submit pull requests.
MIT © Javad Nasrollahi