sauber-php/framework

The Sauber PHP framework

Fund package maintenance!
juststeveking

dev-main 2022-05-30 08:25 UTC

This package is not auto-updated.

Last update: 2024-06-11 16:39:18 UTC


README

banner-direct.svg

Sauber PHP Framework

GitHub release (latest by date) Tests Static Analysis Total Downloads GitHub

This is the repository for the Sauber PHP Framework.

Installation

You should not need to install this package, you should use the sauber-php/sauber template instead, but if you would like to manually build your template, please install using composer:

composer require sauber-php/framework

Usage

To use this package outside of the template, you will need to instantiate it yourself.

Using the Applications static boot method

use Sauber\Framework\Application;
use Sauber\Container\Container;

$app = Application::boot(
    container: new Container(),
);

// Register routes here ...

$app->run();

Manually creating the Application

use Sauber\Container\Container;
use Sauber\Framework\Application;
use Sauber\Http\HttpKernel;
use Sauber\Http\Router;

$container = new Container();
$router = new Router(
    container: $container,
);

$app = new Application(
    router: $router,
    kernel: HttpKernel::using(
        router: $router,
    ),
    container: $container,
);

// Register routes here ...

$app->run();

Using the dispatch method

use Sauber\Container\Container;
use Sauber\Framework\Application;
use Sauber\Http\Request;

$app = Application::boot(
    container: new Container(),
);

// Register routes here ...

$app->dispatch(
    request: Request::capture(),
);

Testing

To run the tests:

./vendor/bin/pest

Static Analysis

To check the static analysis:

./vendor/bin/phpstan analyse

Changelog

Please see the Changelog for more information on what has changed recently.