2017 © Pedro Peláez
 

library fol

Base App class to build websites

image

oscarotero/fol

Base App class to build websites

  • Friday, September 22, 2017
  • by oscarotero
  • Repository
  • 1 Watchers
  • 1 Stars
  • 509 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 21 % Grown

The README.md

Fol

Latest Version on Packagist ![Software License][ico-license] Build Status ![Quality Score][ico-scrutinizer], (*1)

This is a simple class with some utils to build websites with the following features:, (*2)

Paths and URI

Manage the path of the app and the public uri using the UriInterface from PSR-7:, (*3)

use Fol\App;
use Zend\Diactoros\Uri;

$path = '/var/www/my-website';
$uri = new Uri('http://localhost/my-website');

$app = new App($path, $uri);

//Get the path
$app->getPath(); // /var/www/my-website
$app->getPath('dir/subdir', '../other'); // /var/www/my-website/dir/other

//Get the uri
(string) $app->getUri(); // http://localhost/my-website
(string) $app->getUri('post/1', 'details'); // http://localhost/my-website/post/1/details

PSR-11

It's compatible with PSR-11 and container-interop/service-provider, and allows to nest other containers:, (*4)

use Fol\App;
use Zend\Diactoros\Uri;

$app = new App(__DIR__, new Uri('http://localhost/my-website'));

//Set a value
$app->set('database.config', [
    'user' => 'foo',
    'pass' => 'bar'
]);

//Get the value
$config = $app->get('database.config');

//Set a service
$app->addService('database', function ($app) {
    return new DatabaseClass($app->get('database.config'));
});

//Get the service value
$database = $app->get('database');

//And add ServiceProviderInterface instances to register several dependencies
$app->addServiceProvider(new MyServiceProvider());

Please see CHANGELOG for more information about recent changes., (*5)

The MIT License (MIT). Please see LICENSE for more information., (*6)

The Versions