Core package of the Miniframe PHP Framework
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.
Core classes explained
This framework contains a few core classes. These classes are used in this core:
|AbstractController||All Controllers should extend this. It contains the |
|AbstractMiddleware||All Middlewares should extend this. It contains the |
|Bootstrap||The kickstarter of this framework.|
|Config||Parses the configuration files and provides an interface to request it's contents.|
|Registry||Registry that can be used to store and later retrieve objects.|
|Request||Parses the web request and provides an interface to read the request.|
|Response||Populate (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:
|UrlToMvcRouter||URL To MVC Router; documentation at src/Middleware/UrlToMvcRouter.md|
|BasicAuthentication||Basic HTTP Authentication; documentation at src/Middleware/BasicAuthentication.md|
|Session||PHP Sessions; documentation at src/Middleware/Session.md|
|AccessList||Deny / Allow clients based by their IP; documentation at src/Middleware/AccessList.md|
A full list of middlewares can be found at https://miniframe.dev/middlewares
Pre-defined response types included in the Core bundle
|Response||Success||Main Response object, extended by all others.|
|JsonResponse||Success||Returns the data formatted as JSON.|
|PhpResponse||Success||Uses PHP templates to create a proper response.|
|StreamResponse||Success||A basic 200 OK response for large files.|
|RedirectResponse||Success||A basic 30? Redirect page.|
|UnauthorizedResponse||Error||A basic 401 Unauthorized page.|
|ForbiddenResponse||Error||A basic 403 Forbidden page.|
|NotFoundResponse||Error||A basic 404 Not Found page.|
|InternalServerErrorResponse||Error||A 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
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.