weew / app
Very minimalistic wrapper for a php application.
Requires
- weew/commander-container-aware: ^2.0
- weew/config: ^1.1
- weew/container: ^1.0
- weew/contracts: ^1.1
- weew/eventer-container-aware: ^2.0
- weew/helpers-array: ^1.0
- weew/helpers-string: ^1.1
- weew/kernel-container-aware: ^2.0
Requires (Dev)
- phpunit/phpunit: ^4.7
- satooshi/php-coveralls: ^0.6.1
README
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: