Download the PHP package simplemvc/framework without Composer

On this page you can find all versions of the php package simplemvc/framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package framework

SimpleMVC

Build status

SimpleMVC is an MVC framework for PHP based on the KISS principle:

"Keep It Simple, Stupid"

The goal of this project is to offer a simple to use and fast framework for PHP applications using PSR standards.

SimpleMVC uses the dependency injection pattern to manage the dependencies between classes and the FastRoute library for implementing the routing system.

SimpleMVC uses the following PSR standards, from the PHP-FIG initiative:

This project was born as educational library for the course PHP Programming by Enrico Zimuel at ITS ICT Piemonte in Italy.

Since than, the project has been evoluted and used also for building web application in production. We decided to create a more general purpose project and this was the beginning of this repository.

Introduction

SimpleMVC implements the Model–View–Controller (MVC) architectural pattern using Dependency injection and PSR standards.

A SimpleMVC application looks as follows:

In this example we use a DI container with PHP-DI. We create a SimpleMVC\App object using the previous container.

The application can be configured using the config/container.php file. An example is as follows:

The steps to manage the request are:

The dispatch() returns a PSR-7 response. Finally, we can render the response using an emitter. In this example we used a SapiEmitter to render the PSR-7 response in the standard output.

The previous PHP script is basically a front controller of an MVC application (see diagram below).

In this diagram the front controller is stored in a public/index.php file. The public folder is usually the document root of a web server.

Using a pipeline of controllers

If you want you can specify a pipeline of controllers to be executed for a specific route. For instance, imagine to have a route as follows:

The route GET /admin will execute the BasicAuth controller first and, if the authentication will be successfull, the HomePage controller after.

This is a pipeline of two controllers executed in order. The BasicAuth is a simple implementation of the Basic Access Authentication. This controller uses the username and password configuration in the authentication section.

If the authentication is not success, the BasicAuth emits an HaltResponse that will stop the pipeline execution. HaltResponse is a special PSR-7 that informs the SimpleMVC framework to halt the execution.

Passing attributes between controllers

If you need to pass an attribute (parameter) from a controller to another in a pipeline of execution you can use the AttributeInterface. For instance, imagine to pass a foo attribute from a controller A to controller B, using the follwing routing pipeline:

You need to create the controller A as follows:

We can use an AttributeTrait that implements the AttributeInterface with the addRequestAttribute(string $name, $value). This function adds a PSR-7 attribute into the $request for the next controller.

In order to get the foo parameter in the B controller you can use the PSR-7 standard function getAttribute() from the HTTP request, as follows:

Notice that you don't need to implement the AttributeInterface for the B controller since we only need to read from the $request.

Quickstart

You can start using the framework with the skeleton application.

Copyright

The author of this software is Enrico Zimuel and other contributors.

This software is released under the MIT License.


All versions of framework with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
nikic/fast-route Version ^1.3
nyholm/psr7 Version ^1.5
nyholm/psr7-server Version ^1.0
psr/log Version ^1|^2|^3
psr/http-client Version ^1.0
psr/container Version ^1.0 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package simplemvc/framework contains the following files

Loading the files please wait ....