PHPackages                             php-mvc-project/php-mvc - 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. php-mvc-project/php-mvc

ActiveLibrary[Framework](/categories/framework)

php-mvc-project/php-mvc
=======================

Implementation of the MVC (Model-View-Controller) architectural pattern in PHP.

v1.2.0(7y ago)166927[4 issues](https://github.com/php-mvc-project/php-mvc/issues)MITPHPPHP &gt;=7.0CI failing

Since May 29Pushed 7y agoCompare

[ Source](https://github.com/php-mvc-project/php-mvc)[ Packagist](https://packagist.org/packages/php-mvc-project/php-mvc)[ RSS](/packages/php-mvc-project-php-mvc/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

PHP MVC
=======

[](#php-mvc)

[![PHP from Packagist](https://camo.githubusercontent.com/1b40d3c772703864384b288d334b1c5962078985bf1be09daf8731886a177fb6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068702d6d76632d70726f6a6563742f7068702d6d76632e7376673f7374796c653d666c6174)](http://php.net)[![License](https://camo.githubusercontent.com/cce1688cd6bcb405e2bfd80ea2750bc6e1e905d7769d701a7ada7cc7357d7533/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068702d6d76632d70726f6a6563742f7068702d6d76632e7376673f7374796c653d666c6174)](LICENSE)[![GitHub release](https://camo.githubusercontent.com/762c65628d524557b31e7a789088cd525dfb2e811902299923743842c7339f6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7068702d6d76632d70726f6a6563742f7068702d6d76632e737667)](https://github.com/php-mvc-project/php-mvc/releases)[![Packagist](https://camo.githubusercontent.com/07f2253fbb9807a709d4490e953bee104ca15729ed622428889e1febd1e5d35f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d6d76632d70726f6a6563742f7068702d6d76632e737667)](https://packagist.org/packages/php-mvc-project/php-mvc)

The best implementation of the **Model-View-Controller** architectural pattern in **PHP**!

Features
--------

[](#features)

- Templates
- Routing
- Filters
- Cache
- Validation
- Data annotation
- Security

Requirements
------------

[](#requirements)

- PHP 7.x

Installation
------------

[](#installation)

```
$ composer require php-mvc-project/php-mvc

```

Server Configuration
--------------------

[](#server-configuration)

The server must send the entire request to the `./index.php` file.

### Apache

[](#apache)

```

  RewriteEngine On

  # redirect /index.php to /
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php
  RewriteRule ^index.php/?(.*)$ $1 [R=301,L]

  # process all requests through index.php, except for actually existing files
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1?%{QUERY_STRING} [QSA,L]

```

### nginx

[](#nginx)

```
location / {
  try_files $uri $uri/ /index.php?$args;
}
```

Basic Usage
-----------

[](#basic-usage)

Create the following structure in the project root directory:

```
.
├── controllers           # controllers folder
├─── HomeController.php   # class of the home controller
├─── *Controller.php      # classes of others controllers
├── models                # models folder
├── views                 # views folder
├─── home                 # views folder of the home controller
├─── ...                  # folders for other controllers
├─── shared               # shared views
└── index.php             # index file
```

### ./index.php

[](#indexphp)

```
