2017 © Pedro Peláez
 

library webglue

Framework in one file

image

webglue/webglue

Framework in one file

  • Wednesday, May 1, 2013
  • by wkjagt
  • Repository
  • 1 Watchers
  • 1 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WebGlue

WebGlue is a tiny web framework. Actually it's nothing more than some glue between the Symfony HttpFoundation Request and Response object, and a very simple router. I find it helps me a lot for quick prototyping and small projects., (*1)

Usage

Very simple:, (*2)

  1. Instantiate WebGlue
  2. Add services to instance using array notation (optional)
  3. Add routes using following syntax $app-><method>(<route>, <callback>);
  4. Your callback will get 3 arguments passed to it: the WebGlue instance, a request object, a response object
  5. Modify the response to your needs. You don't need to return it.

Examples

Hello Willem

$app = new WebGlue;

// for routes accepting POST, use $app->post, etc.
$app->get('/', function($app, $request, $response){
    $response->setContent('hello world');
});

$app->get('/greet/{name:string}', function($app, $request, $response){
    $name = $request->attributes->get('name');
    $response->setContent('hello ' . $name);
});

$app->run();

Add services

$app = new WebGlue;

// add the excellent Twig templating engine
$app['twig'] = new Twig_Environment(new Twig_Loader_Filesystem(__DIR__.'/templates'));

$app->get('/', function($app, $request, $response){
    $response->setContent(app['twig']->render('hello_world.html.twig'));
});

Use composer

Only master for now..., (*3)

{
    "require" : {
        "webglue/webglue": "dev-master"
    }
}

and, (*4)

include __DIR__.'/vendor/autoload.php';

The Versions

01/05 2013

dev-master

9999999-dev

Framework in one file

  Sources   Download

MIT

The Requires

 

framework