Application

Manually create HTTP application

To create a new HTTP Application instance, you need at least 3 things:

Also, you can optionally set a Dictionary for your application properties

use Peak\Bedrock\Http\Application;
use Peak\Bedrock\Kernel;
use Peak\Collection\PropertiesBag;
use Peak\Di\Container;
use Peak\Http\Request\HandlerResolver;

$container = new Container();
$app = new Application(
    new Kernel('prod', $container),
    new HandlerResolver($container),
    new PropertiesBag([ // optional
        'version' => '1.0',
        'name' => 'app'
    ])
);

Creating an application using HttpAppBuilder()

This is the easiest and fastest way to create an application.

Be advise though by default, HttpAppBuilder will assume dependencies for you if you don’t specify anything.

use Peak\Backpack\Bedrock\HttpAppBuilder;

$httpAppBuilder = new HttpAppBuilder();
$app = $httpAppBuilder
    ->setProps([
        'version' => '1.0',
        'name' => 'app'
    ])
    ->build();
Configure environment with setEnv()

By default, environment is set to prod. To change that:

$httpAppBuilder->setEnv('dev');
Change the Kernel Class setKernelClass()

By default, class Peak\\Bedrock\\Kernel is used. To change that:

$httpAppBuilder->setKernelClass(MyAppKernel::class);
Change the container

By default, class Peak\Di\Container is used. To change that

$httpappBuilder->setKernelClass(MyAppKernel::class);