PHPackages                             raoul/mvc-framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. raoul/mvc-framework

ActiveProject[Framework](/categories/framework)

raoul/mvc-framework
===================

V2.0.2(2y ago)814[1 PRs](https://github.com/RaoulvanWijk/mvc/pulls)PHPPHP ^8.2

Since Dec 1Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/RaoulvanWijk/mvc)[ Packagist](https://packagist.org/packages/raoul/mvc-framework)[ RSS](/packages/raoul-mvc-framework/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (7)Versions (8)Used By (0)

About my mvc Framework
======================

[](#about-my-mvc-framework)

How to install
--------------

[](#how-to-install)

Clone repository

```
git clone https://github.com/RaoulvanWijk/mvc.git

```

Install composer packages

```
composer install

```

Running the framework
---------------------

[](#running-the-framework)

To run the framework you have 2 options: Run it from command line

```
$ php mvc serve
```

or run it by creating a virtual host.

*Note that mvc server uses the [PHP server](https://www.php.net/manual/en/features.commandline.webserver.php) under the hood which is **NOT** meant to used as a web server so only use `mvc serve` for development purposes!*

**And make sure you are running your database if you want to use it**

Routing
-------

[](#routing)

Go to the web.php file in the routes folder

```
use App\Http\Route;
use App\Http\Controllers\DemoController;

Route::get('url', [DemoController:class, 'method'], "name");
Route::post('url', [DemoController:class, 'method'], "name");
Route::put('url', [DemoController:class, 'method'], "name");
Route::delete('url', [DemoController:class, 'method'], "name");
```

Route parameters

```
Route::get('url/{id}/another/{param}', [DemoController:class, 'method'], "name");
```

### Grouped routes

[](#grouped-routes)

```
Route::prefix('/demo')->group(function() {
  	Route::get('url', [DemoController:class, 'method'], "route");
    Route::get('url', [DemoController:class, 'method'], "anotherRouteInGroup");
});
```

Middleware
----------

[](#middleware)

Middleware is used to validate the uri request

### Creating middleware

[](#creating-middleware)

To create middleware execute the following command:

```
$ php mvc make:middleware NameOfTheMiddleware
```

### Adding middleware to a route

[](#adding-middleware-to-a-route)

Adding middleware to a single route

```
Route::get('url', [DemoController:class, 'method'], "anotherRouteInGroup", middleware: "nameOfMiddleware");
```

Adding middleware to grouped routes

```
Route::prefix('/demo')->group(function() {
  Route::get('/url', [DemoController:class, 'method'], "route");
}, ["middleware" => ["nameOfMiddleware"]]);
```

To specify new middleware to go app\\Http\\HttpKernel and add youre middleware class to

```
  private $routeMiddleware = [
    "nameOfMiddleware" => \App\Http\Middleware\YoureMiddlewareClass
  ];
```

Controllers
-----------

[](#controllers)

A controller is used to communicate between a view and a model

### Creating a controller

[](#creating-a-controller)

You can create a controller by using the following command:

```
$ php mvc make:controller YoureNameOfTheController
```

### Routing in a controller

[](#routing-in-a-controller)

```
class DemoController extends Controller
{
  public function demo()
  {
    // Redirect to different route
    $this->redirect('name_of_route');

    // Redirect with a message
    $this->redirect('name_of_route')->with('key', 'value');

    // Go to previous route
    $this->back();
  }
}
```

### Rendering a view

[](#rendering-a-view)

```
class DemoController extends Controller
{
  public function demo()
  {
    // Filename in resources folder
    $this->view('file');

  }
}
```

Models
------

[](#models)

A model is used to interact with the database

### Creating a Model

[](#creating-a-model)

You can create a model by using the following command:

```
$ php mvc make:model YoureNameOfTheModel
```

The name you give to the model wil also be parsed to the name of your database table for example:

```
class User
```

will by default have **users** as table name

You can change the name of databaseTable by adding

```
protected $databaseTable = 'tablename';
```

### Model properties

[](#model-properties)

Below a list of properties that you can change

```
   /**
   * Var used to store the database Table of the model
   */
  protected string $databaseTable;

  /**
   * Var used to keep track of tables primary key
   */
  protected string $primaryKey = 'id';

  /**
   * Var used to store all the columns that are allowed to be inserted
   */
  protected array $fillable = [];
```

### Model Query Builder

[](#model-query-builder)

This model also has a query builder wich you can use example below

```
  public function Demo()
  {
  // Using not Raw functions are **NOT SAFE** using this without sanitizing the user input is not recommended
    return Progress::select()->where('id = 1')->get();

    // using Raw functions are safer since it is using prepared statements with binding
    return Progress::select()->whereRaw('id = :id', [':id', 1])->get();

    // But you should still always sanitize the user input
  }
```

If you dont want to use the query builder you can also execute sql statements by using:

```
  public function Demo()
  {
    return Progress::query('SELECT * FROM users');
  }
```

At the end of every builded query you need to use

```
->get();
```

to execute the sql statement

Requests
--------

[](#requests)

In this framework you can use a request class to validate the request data before it gets to the controller and redirects the user back to the previous page with a errors

### Creating a request class

[](#creating-a-request-class)

To create a request class use the following command

```
$ php mvc make:request NameOfRequestClass
```

### Specifying the rules

[](#specifying-the-rules)

To validate the data you need to use the `rules()` function as following:

```
  public function rules()
  {
    return [
      'username' => 'required|string|min:8',
      'password' => 'required|string|min:8'
    ];
  }
```

You can also specify what url the request is gona redirect to if it has failed

```
$redirect_if_failed = 'name_of_route';
```

### using `authorize()`

[](#using-authorize)

U can use the authorize function to validate if a user is allowed to make the request if `authorize()` doesnt return true it will throw en error

```
  public function authorize()
  {
    return true;
  }
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance50

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 74.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~69 days

Total

5

Last Release

984d ago

Major Versions

v0.1.0 → v1.0.02022-12-28

v1.0.0 → v2.0.02023-02-25

PHP version history (2 changes)v0.1.0PHP ^8.1

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/689dc11738f4bf48182a351288ecdc0354cf6559ebb03a9c51bc216a8a96ada0?d=identicon)[RaoulvanWijk](/maintainers/RaoulvanWijk)

---

Top Contributors

[![RaoulvanWijk](https://avatars.githubusercontent.com/u/72564782?v=4)](https://github.com/RaoulvanWijk "RaoulvanWijk (141 commits)")[![Raoul-van-Wijk](https://avatars.githubusercontent.com/u/94360844?v=4)](https://github.com/Raoul-van-Wijk "Raoul-van-Wijk (36 commits)")[![CommandString](https://avatars.githubusercontent.com/u/44886996?v=4)](https://github.com/CommandString "CommandString (12 commits)")

### Embed Badge

![Health badge](/badges/raoul-mvc-framework/health.svg)

```
[![Health](https://phpackages.com/badges/raoul-mvc-framework/health.svg)](https://phpackages.com/packages/raoul-mvc-framework)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.3k86.3M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[spiral/framework

Spiral, High-Performance PHP/Go Framework

2.0k1.8M57](/packages/spiral-framework)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
