[Archived]
Due to lack of time, this project is no longer under development.
About
A simple, light and fast PHP framework based on middlewares.
Create an app
In order to create your application based on Nano Framework, you have to extend the AbstractApplication
class and
setup the middlewares queue of the application. The method
AbstractApplication::middleware(MiddlewareQueue $middleware)
must be overwritten in order to setup the middlewares
queue used to process the server request and create the response. Note that the order in which the middlewares are
added defines the order in which they are executed.
A basic example:
class YourApplication extends AbstractApplication {
public function middleware(MiddlewareQueue $middleware)
{
$middleware
->add(ErrorHandlerMiddleware::class) // Error/Exception handling.
->add(ResponseEmitterMiddleware::class) // Send response to the user.
->add(BufferOutputMiddleware::class) // Output buffering and compressing.
->add(RoutingMiddleware::class); // Routing engine.
}
}
The AbstractApplication
class implements MiddlewareInterface
as it is always the last middleware in the
queue. Its job is to dispatch the server request to an action in order to produce a response. The action to be
executed is a callable set as attribute in the server request. In this example, this is automatically made by
the RoutingMiddleware
.
Now, you have to start your application from your index.php
file:
require dirname(__DIR__) . '/vendor/autoload.php';
$config = require dirname(__DIR__) . '/config/config.php';
$app = new \App\YourApplication($config);
$app->run();
That's it. Now you have to implement the logic of your application.
Requirements
- PHP >= 7.2
- JSON PHP Extension
- PDO PHP Extension
Documentation
Documentation for this project is available in the docs folder.
License
The Nano Framework is open-sourced software licensed under the MIT license.