2017 © Pedro Peláez
 

library charcoal-app

Charcoal application, based on Slim 3

image

locomotivemtl/charcoal-app

Charcoal application, based on Slim 3

  • Thursday, June 7, 2018
  • by mducharme
  • Repository
  • 11 Watchers
  • 10 Stars
  • 12,231 Installations
  • PHP
  • 8 Dependents
  • 1 Suggesters
  • 3 Forks
  • 0 Open issues
  • 48 Versions
  • 7 % Grown

The README.md

Charcoal App

![License][badge-license] Latest Stable Version ![Code Quality][badge-scrutinizer] Coverage Status ![SensioLabs Insight][badge-sensiolabs] Build Status, (*1)

Charcoal App is a PHP framework to create web applications and APIs using Charcoal components., (*2)

The framework is built on top of Slim 3 and Pimple., (*3)


The Charcoal App is a collection of modules, routes_ (templates, actions and scripts), _handlers, and services tied together with a config, a service container, and service providers., (*4)

The framework features (internally and externally) the following:, (*5)

  • 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

† Provided by external Charcoal components, (*6)

Table of Contents

Installation

The preferred (and only supported) way of installing charcoal-app is with composer:, (*7)

★ composer require locomotivemtl/charcoal-app

From Boilerplate

This module is intended to be used as the base for a web aplication (such as a website)., (*8)

For a complete, ready-to-use project, start from the official boilerplate:, (*9)

★ composer create-project locomotivemtl/charcoal-project-boilerplate

Dependencies

Required

PSR

  • PSR-3: Common interface for logging libraries. Fulfilled by Monolog.
  • PSR-6: Common interface for caching libraries. Fulfilled by Stash.
  • PSR-7: Common interface for HTTP messages. Fulfilled by Slim.
  • PSR-11: Common interface for dependency containers. Fulfilled by Pimple.

👉 Development dependencies, which are optional when using charcoal-app in a project, are described in the Development section of this README file., (*10)

Read the composer.json file for more details on dependencies., (*11)

In addition to the above dependencies, here's a list of recommended modules that can be added to a project., (*12)

Using the charcoal-project-boilerplate is really the recommended way of making sure a "full" Charcoal application is set up., (*13)

To install:, (*14)

★ composer create-project locomotivemtl/charcoal-project-boilerplate
  

Components

The main components of the Charcoal App are:, (*15)

Learn more about components., (*16)

Service Providers

Dependencies and extensions are handled by a dependency container, using Pimple, which can be defined via _service providers_ (Pimple\ServiceProviderInterface)., (*17)

Included Providers

The Charcoal App comes with several providers out of the box. All of these are within the Charcoal\App\ServiceProvider namespace:, (*18)

External Providers

The Charcoal App requires a few providers from independent components. The following use their own namespace and are automatically injected via the AppServiceProvider:, (*19)

Learn more about service providers., (*20)

Usage

Typical Front-Controller (www/index.php):, (*21)

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-project-boilerplate., (*22)

Development

To install the development environment:, (*23)

$ composer install

To run the scripts (phplint, phpcs, and phpunit):, (*24)

$ composer test

API Documentation

Development Dependencies

Coding Style

The charcoal-cache module follows the Charcoal coding-style:, (*25)

Coding style validation / enforcement can be performed with composer phpcs. An auto-fixer is also available with composer phpcbf., (*26)

Credits

License

Charcoal is licensed under the MIT license. See LICENSE for details., (*27)

The Versions