radmen / fatso
Silex fat cousin
Requires
- php: >=5.3.3
- silex/silex: 1.0.*
- symfony/console: 2.2.x-dev
- symfony/finder: 2.2.x-dev
- symfony/yaml: 2.2.x-dev
This package is auto-updated.
Last update: 2019-02-20 19:30:33 UTC
README
Silex is great micro-framework, but it's sometimes just too simple. Fatso is his fat cousin.
It provides very simple, basic classes and automates few things.
Fatso can:
- detect environment based on host name
- load config files (plain PHP arrays, or YAML) and merge thme with their env variants
- perform simple bootstrap of Silex providers
- load routes from config file
Fatso is ugly.
Fast class overview
TL;DR - goto: demo
Config
Config loads files from $app['config.dir']
path.
It also uses env name to merge basic config with it's env variant.
Config can load PHP, or YML files.
Example:
config/foo.yml:
foo: name: bar env: null
config/foo_dev.php:
<?php return array( 'foo' => array( 'env' => 'dev', ), );
$config = $app['config']->get('foo'); /* $config = array( 'foo' => array( 'name' => 'bar', 'env' => 'dev', ), ); */
Env
Performs simple environment detection based on host name.
Before running env variable $app['env.host']
must be set.
$app['env']->get(); // return current env name or NULL if not detected $app['env']->getEnvironments(); // returns list of declared environments.
Environments are defined in config file named env
:
dev: /\.local\.com$/ prod: //
Bootstrap
Bootstrap is responsible for env detection, Silex providers registration and route registration.
Routes are defined in config file named routing
:
<?php return array( 'main' => array( 'pattern' => '/', 'controller' => 'App:Main:index', // resolves to: \App\Controller\Main::index 'method' => 'get', // can be set to: GET, POST, PUT, DELETE, or MATCH. Default is GET ), );
To register some providers in config dir must be created folder named bootstrap
with providers config files.
Sample provider config file:
\Silex\Provider\TwigServiceProvider: twig.path: 'view/'
Fatso-skeleton
There's also sample Fatso skeleton, check it out to see how Fatso works.