https://github.com/carlbennett/php-mvc
A PHP micro-framework for use as a frontend and/or backend
https://github.com/carlbennett/php-mvc
backend composer framework frontend mvc mvc-framework php utility
Last synced: 3 months ago
JSON representation
A PHP micro-framework for use as a frontend and/or backend
- Host: GitHub
- URL: https://github.com/carlbennett/php-mvc
- Owner: carlbennett
- License: agpl-3.0
- Created: 2015-10-21T07:54:49.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2022-11-13T18:50:06.000Z (over 3 years ago)
- Last Synced: 2025-09-04T19:53:42.160Z (7 months ago)
- Topics: backend, composer, framework, frontend, mvc, mvc-framework, php, utility
- Language: PHP
- Homepage:
- Size: 158 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# php-mvc
[](https://github.com/carlbennett/php-mvc/actions?query=workflow%3Aphp-mvc)
**php-mvc** is a PHP standard library used with [@carlbennett](https://githhub.com/carlbennett)'s projects. The aspirations of this library are for a project website to include it as middleware.
## Installation
This library is available via [composer](https://getcomposer.org) from [packagist](https://packagist.org/packages/carlbennett/php-mvc).
```sh
composer require carlbennett/php-mvc
composer install
```
## Usage
The following is an example of including this library in your project. This
assumes you have already installed the library via composer.
```php
addRoute( // URLs: /home, /home.htm, /home.html
// pattern, model, view
'#^/home(?:\.html?)?$#', 'Home', 'HomeHtml'
);
$router->route();
$router->send();
// Custom template engine powered by pure PHP, utilizes include() and output buffers.
$context = null; // empty context, used to pass state to template
(new Template($context, 'HelloWorld'))->render(); // prints ./src/Templates/HelloWorld.phtml to the client.
// A dynamic error handler. Prints JSON if display_errors is ON, a friendly html page if OFF.
GlobalErrorHandler::createOverrides();
throw new RuntimeException('test');
```