2017 © Pedro Peláez
 

library fatso

Silex fat cousin

image

radmen/fatso

Silex fat cousin

  • Wednesday, December 12, 2012
  • by radmen
  • Repository
  • 1 Watchers
  • 1 Stars
  • 12 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

What is Fatso?

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., (*1)

Fatso can:, (*2)

  • 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., (*3)

Fast class overview

TL;DR - goto: demo, (*4)

Config

Config loads files from $app['config.dir'] path.
It also uses env name to merge basic config with it's env variant., (*5)

Config can load PHP, or YML files., (*6)

Example:, (*7)

config/foo.yml:, (*8)

foo:
    name: bar
    env: null

config/foo_dev.php:, (*9)

<?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., (*10)

$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:, (*11)

dev: /\.local\.com$/
prod: //

Bootstrap

Bootstrap is responsible for env detection, Silex providers registration and route registration., (*12)

Routes are defined in config file named routing:, (*13)

<?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., (*14)

Sample provider config file:, (*15)

\Silex\Provider\TwigServiceProvider:
  twig.path: 'view/'

Fatso-skeleton

There's also sample Fatso skeleton, check it out to see how Fatso works., (*16)

The Versions

12/12 2012

dev-master

9999999-dev

Silex fat cousin

  Sources   Download

MIT

The Requires