2017 © Pedro Peláez
 

library backbeard

yet another DSLish minimum oriented framework for PHP

image

sasezaki/backbeard

yet another DSLish minimum oriented framework for PHP

  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

Backbeard

Backbeard is yet another DSLish minimum oriented framework for PHP., (*1)

Build Status Coverage Status, (*2)

backbeard, (*3)

Principle

yield $router($request) => $action();, (*4)

Usage

<?php
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Backbeard\Dispatcher;
use Backbeard\ValidationError;

$routingFactory = function ($container) {
    yield '/hello' => 'hello';

    $error = (yield ['POST' => '/entry/{id:[0-9]}'] => function ($id) {
        if ($this->getRequest()->getPost()['NAME'] == 'wtf') {
            return ['var1' => 'baz']; // will be render entry.phtml
        } else {
            return new ValidationError(['error message!']);
        }
    });

    yield '/entry/{id:[0-9]}' => function ($id) use ($error) {
        $message = $error ? htmlspecialchars(current($error->getMessages())) :'';
        return "Hello $id ".$message.
        '<form method="POST" action="/entry/'.$id.'">'.
            'NAME<input type="text" name="NAME">'.
        '</form>';
    };

    yield [
      'GET' => '/foo',
      'Header' => [
        'User-Agent' => function($headers){
          if (!empty($headers) && strpos(current($headers), 'Coffee') === 0) {
            return true;
          }
        }
      ]
    ] => function () {
        return $this->getResponseFactory()->createResponse(418);
    }; // status code "I'm a teapot"

    yield (ServerRequestInterface $request) {
        return true;
    } => function () {
        /** @var ResponseInterface $this */
        return $this;
    };
};

(new Dispatcher($routingFactory($container)))->dispatch(new Request);

Install with composer

  • composer require sasezaki/backbeard dev-master

Using As Middleware for zend-stratigility

https://github.com/struggle-for-php/sfp-stratigility-skeleton, (*5)

  • php composer.phar create-project -s dev struggle-for-php/sfp-stratigility-skeleton path/to/install, (*6)

    When install finished, you can try running with php built-in web server, (*7)

  • php -S localhost:8080 -t public/ public/index.php

NOTES

THIS PROJECT IS A PROOF OF CONCEPT FOR GENERATOR BASED ROUTER, AND NOT INTENDED FOR PRODUCTION USE. PLEASE USE AT YOUR OWN RISK., (*8)

The Versions

18/11 2016

dev-master

9999999-dev

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr-7 psr7 router

03/11 2015

0.7.0

0.7.0.0

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr-7 psr7 router

02/11 2015

0.6.0

0.6.0.0

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr-7 psr7 router

30/10 2015

0.5.1

0.5.1.0

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr-7 psr7 router

30/10 2015

0.5.0

0.5.0.0

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr-7 psr7 router

29/10 2015

0.4.0

0.4.0.0

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr-7 psr7 router

02/07 2015

0.3.0

0.3.0.0

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr-7 psr7 router

02/07 2015

v0.2.1

0.2.1.0

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr-7 psr7 router

21/05 2015

v0.2.0

0.2.0.0

yet another DSLish minimum oriented framework for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

psr7 microframework

12/01 2014
12/01 2014