Download the PHP package robertwesner/simple-mvc-php without Composer
On this page you can find all versions of the php package robertwesner/simple-mvc-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download robertwesner/simple-mvc-php
More information about robertwesner/simple-mvc-php
Files in robertwesner/simple-mvc-php
Package simple-mvc-php
Short Description A small library for creating PHP web servers.
License MIT
Informations about the package simple-mvc-php
Simple MVC for PHP



[](../../raw/main/LICENSE.txt)
A small library for creating PHP web servers.
Initially created for private use in place of Node-JS when creating very simple websites. Now able to run more complex applications. Feel free to use if it fits your needs.
Websites using this:
Features
- Request handling (
GET
,POST
,PUT
,PATCH
,DELETE
)- Query parameters
- JSON parameters
- URI parameters
- Intuitive Syntax
- Simple to use composer template
- Integrated Twig templating engine
- [Optional] Autowiring of controller dependencies
- [Optional] Ability to load external bundles
Installation
New Docker project
This creates a Docker PHP-FPM + Nginx Project and is the preferred way of use.
New project
This creates a new project with the required folder structure.
Existing project
If you already have a project, require the package and migrate your files manually.
Usage
Project structure
Routing scripts
You can create any amount of routing scripts. They define a mapping between a URL and a controller function or method.
Example:
api.php
view.php
Using Controller Classes
More complex Logic can be handled with class controllers.
Resolving the controller requires robertwesner/dependency-injection.
See: demo routing
Autowiring
Installing robertwesner/dependency-injection allows for automatic resolution of Route dependencies:
Configuration
Configurations are optional and stored in $PROJECT_ROOT$/configuration
, written in PHP.
You can run this server with zero configuration if you do not need the following features.
Container
File: container.php
Configures additional autowiring steps if you intend to use robertwesner/dependency-injection
in complex use cases.
You can manually define container instances with this configuration.
Bundles
File bundles.php
Loads external bundles (implementing BundleInterface) which may configure their own Container values.
Feel free to store configurations for your bundles in a subfolder inside
$PROJECT_ROOT$/configuration
.Example:
$PROJECT_ROOT$/configurations/database/database.yml
Error handling
Requires the use of configuration files, refer to the previous section for mor information.
Use your preferred ThrowableHandler by instantiating it as ThrowableHandlerInterface
.
By default, without registering a handler, no exception information will be stored or printed.
Example: PrintThrowableHandler outputs directly to the browser
Example: StdoutThrowableHandler outputs into the server stderr and doesn't leak to the browser
You can implement your own handler quite easily for additional tasks like sending automated mails.