weew/app

Very minimalistic wrapper for a php application.

v2.10.1 2016-07-21 11:12 UTC

README

Build Status Code Quality Test Coverage Version Licence

Table of contents

Installation

composer require weew/app

Introduction

This package is meant to be used as a barebone for any php applications. It uses the weew/container package for dependency injection, weew/kernel as a kernel where you can register your providers, the weew/eventer package for event handing and the weew/commander package as the command bus. Configuration is handled by the weew/config package.

Please read documentation of different components to see how they work.

Usage

Creating a new app is very simple:

$app = new App('environment');

// or

$app = new App();
$app->setEnvironment('environment');

// get depdency injection container
$app->getContainer();

// get kernel
$app->getKernel();

// get event bus
$app->getEventer();

// get command bus
$app->getCommander();

You can provide config sources using the config loader.

// get config
$app->getConfigLoader()
    ->addPath('/path/to/config')
    ->addRuntimeConfig(['some' => 'value']);

Be aware that applications current environment and debug mode will always be available inside the config object.

// "dev" by default
$app->getEnvironment();
$app->setEnvironment('test');
// will be set to test
$app->getConfig()->get('env');

// false by default
$app->getDebug();
$app->setDebug(true);
// will be set to true
$app->getConfig()->get('debug');

Be aware that config is only available after the application start.

Extensions

There are several extensions available: