Core package of the Miniframe PHP Framework

v1.3.0 2024-09-26 08:44 UTC

This package is auto-updated.

Last update: 2024-10-26 11:15:25 UTC


README

This is the core package of the Miniframe PHP Framework. For more information, see the Main project at https://bitbucket.org/miniframe/miniframe-php-framework.

build code coverage

Core classes explained

This framework contains a few core classes. These classes are used in this core:

ClassDescription
AbstractControllerAll Controllers should extend this. It contains the Request and Config object.
AbstractMiddlewareAll Middlewares should extend this. It contains the Request and Config object.
BootstrapThe kickstarter of this framework.
ConfigParses the configuration files and provides an interface to request it's contents.
RegistryRegistry that can be used to store and later retrieve objects.
RequestParses the web request and provides an interface to read the request.
ResponsePopulate (or extend) this object in a Controller to return something to the client.

Middlewares included in the Core bundle

In the main project, you'll see a middleware directive in the configuration. Multiple middlewares can be loaded, and are loaded in the sequence in which they are configured.

These middlewares are included in this Miniframe Core bundle and can be used to quickly set up a basic application, or as example for building your own middleware classes:

Class nameDescription
UrlToMvcRouterURL To MVC Router; documentation at src/Middleware/UrlToMvcRouter.md
BasicAuthenticationBasic HTTP Authentication; documentation at src/Middleware/BasicAuthentication.md
SessionPHP Sessions; documentation at src/Middleware/Session.md
AccessListDeny / Allow clients based by their IP; documentation at src/Middleware/AccessList.md
ForwardedForParsing X-Forwarded-* headers when proxied; documentation at src/Middleware/ForwardedFor.md

A full list of middlewares can be found at https://miniframe.dev/middlewares

Pre-defined response types included in the Core bundle

Class nameTypeDescription
ResponseSuccessMain Response object, extended by all others.
JsonResponseSuccessReturns the data formatted as JSON.
PhpResponseSuccessUses PHP templates to create a proper response.
StreamResponseSuccessA basic 200 OK response for large files.
RedirectResponseSuccessA basic 30? Redirect page.
UnauthorizedResponseErrorA basic 401 Unauthorized page.
ForbiddenResponseErrorA basic 403 Forbidden page.
NotFoundResponseErrorA basic 404 Not Found page.
InternalServerErrorResponseErrorA basic 500 Internal Server Error page.

A Response object can be returned in a Controller method or being thrown. Throwing responses can especially be useful for error pages.

Tip for Windows Developers

In the bin folder, a few batch files exist, to make development easier.

If you install Docker Desktop for Windows, you can use bin\composer.bat, bin\phpcs.bat, bin\phpunit.bat, bin\phpstan.bat and bin\security-checker.bat as shortcuts for Composer, CodeSniffer, PHPUnit, PHPStan and the Security Checker, without the need of installing PHP and other dependencies on your machine.

The same Docker container and tools are used in Bitbucket Pipelines to automatically test this project.