The App package provides integration with Slim and Pimple for building user-facing Web applications and APIs.
composer require charcoal/app
The App package is a collection of modules, routes (templates
, actions
and scripts
), handlers, and services tied together with a config, a service container, and service providers.
The framework features (internally and externally) the following:
- PSR-3 logger
- PSR-6 cache system[†]
- PSR-7 kernel (web, API, CLI)
- PSR-11 container
- Translation layer[†]
- File system layer
- Database layer
- View layer[†]
Notes:
- [†] Provided by external Charcoal components.
The main components of the Charcoal App are:
Learn more about components.
Dependencies and extensions are handled by a dependency container, using Pimple, which can be defined via service providers (Pimple\ServiceProviderInterface
).
The Charcoal App comes with several providers out of the box. All of these are within the Charcoal\App\ServiceProvider
namespace:
The Charcoal App requires a few providers from independent components. The following use their own namespace and are automatically injected via the AppServiceProvider
:
Learn more about service providers.
Typical front-controller (www/index.php
):
use Charcoal\App\App;
use Charcoal\App\AppConfig;
use Charcoal\App\AppContainer;
include '../vendor/autoload.php';
$config = new AppConfig();
$config->addFile(__DIR__.'/../config/config.php');
$config->set('ROOT', dirname(__DIR__) . '/');
// Create container and configure it (with charcoal/config)
$container = new AppContainer([
'settings' => [
'displayErrorDetails' => true,
],
'config' => $config,
]);
// Charcoal / Slim is the main app
$app = App::instance($container);
$app->run();
For a complete project example using charcoal/app
, see the charcoal/boilerplate.