2017 © Pedro Peláez
 

composer-plugin lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

image

silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  • Friday, June 8, 2018
  • by downsider
  • Repository
  • 10 Watchers
  • 1 Stars
  • 1,333 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 4 Open issues
  • 41 Versions
  • 7 % Grown

The README.md

lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI, (*1)

Summary

Older versions of this project will make templates. Version 5 just works within the constraints of providing the Lazy Boy will create a skeleton Silex framework, so you can create REST APIs without having to bother with boilerplate code., (*2)

It is packaged with a route loader and uses Syringe, which allows you to define both your routes and services in configuration files, rather than PHP, (*3)

(The rest of this Readme is probably nonsense), (*4)

Requirements

Installation

install using composer:, (*5)

composer require silktide/lazy-boy:^2.0

Lazy Boy will automatically generate several files from templates, whenever composer update or composer install is run. You are free to make modifications; Lazy Boy will not overwrite a file which already exists, so committing those changes to a VCS is safe. Having your VCS ignore the files will mean they are generated when you install vendors on a freshly cloned repository., (*6)

If you want to disable automatic file generation, so you can use the FrontController or RouteLoader perhaps, add the following to your composer file:, (*7)

"extra": {
  "silktide/lazy-boy": {
    "prevent-install": true
  }
}

All that is left to do is create a vhost or otherwise point requests to web/index.php., (*8)

Routing

Routes

If you are using the standard Lazy-Boy route loader, you can define your routes in configuration files, using YAML or JSON. Each route is defined as follows:, (*9)

routes:
    route-name:
        url: /sub/directory
        action: "test_controller:doSomething"
        method: post

routes is an associative array of routes that you want to allow access to., (*10)

In this case, a HTTP request that was POSTed to /sub/directory, would access a service in the container called test-controller and call it's method doSomething. This route could be referenced as route-name when using the router., (*11)

For each route, the url and action parameters are required, but method is optional and defaults to GET., (*12)

You can also use the assert parameter to overwrite the default regex for parameter of a route. For example, (*13)

    routes:
        route-one:
            url: /user/{id}
            action: "test_controller:doSomething"
            method: get

The URL /user/56 would match and the id parameter would come back as 56. The URL /user/56/foo would not match., (*14)

    routes:
        route-two:
            url: /user/{my_wildcard}
            action: "test_controller:doSomethingElse
            method: get
            assert:
                my_wildcard: ".*"

Going to the URL /user/56 would match and again, the my_wildcard parameter would come back as 56. Going the the URL /user/56/foo would match and the my_wildcard parameter would return 56/foo, (*15)

Groups

If you have many routes with similar URLs, such as:, (*16)

  • /users
  • /users/{id}
  • /users/login
  • /users/logout

you can use a group to wrap them with a common url prefix., (*17)

groups:
    users:
        urlPrefix: /users
        routes:
            user-list:
                url: /
                action: "..."
            get-user:
                url: /{id}
                action: "..."
            user-login:
                url: /login
                action: "..."
                method: post
            user-logout:
                url: /logout
                action "..."

Imports

if you have a lot of routes, it can be convenient to separate related routes into different files. In this case, you can import files into a parent file by using the imports array:, (*18)

imports:
    - users.yml
    - shop/products.yml
    - shop/checkout.yml

groups:
    group: "..."
routes:
    route: "..."

Imported files are merged into a single configuration array before routes and groups are processed. Where route naming conflicts arise, the latter import will overwrite the former and the importing file will take precedence over any imported routes., (*19)

Custom Templates

Lazy Boy uses a simple template system to create standard config and entry point files. It is possible to hook into this system to extend Lazy Boy and install custom templates., (*20)

The extending library should be used as Lazy Boy is; required into an application as a composer dependency. The library itself should require Lazy Boy as normal, but then add extra data to the composer.json file to configure the templates:, (*21)

{
  "name": "silktide/lazy-boy-extension",
  "require": {
    "lazy-boy": "^2.0.0"
  },
  "extra": {
    "silktide/lazy-boy": {
      "templates": {
        "template-name": {
          "template": "[ file path of the template, relative to the library package root directory]",
          "output": "[ file path of the output file, relative to the application root directory ]"
        },
        "index": {
          "template": "[ the 'index' template already exists. You can override a template like this ... ]"
        },
        "console": {
          "output": "[ ... or change where it's written to by overriding the output ]"
        }
      }
    }
  }
}

As in the example config, you can replace an existing template with a custom one by using the same template name. You can choose to override the template and/or the output file location., (*22)

Currently the following templates are predefined, (*23)

Template Name Output Location
bootstrap * app/bootstrap.php
services app/config/services.yml
routes app/config/routes.yml
console ** app/console.php
index web/index.php
htaccess web/htaccess

* This template is protected and cannot be overridden, (*24)

** This template depends on the symfony/console library being present in the package list, (*25)

Usage In Applications

In order to prevent dependencies from installing templated files ad hoc, Lazy Boy requires that you whitelist the package name in your application, before it will install any custom templates. This is done by adding the following code to the applications composer.json file, (*26)

"extra": {
  "silktide/lazy-boy": {
    "whiteListedPackages": [
      "your/package-name"
    ]
  }
}

Contributing

If you have improvements you would like to see, open an issue in this github project or better yet, fork the project, implement your changes and create a pull request., (*27)

The project uses PSR-2 code styles and we insist that these are strictly adhered to. Also, please make sure that your code works with php 5.4, so things like generators, finally, empty(someFunction()), etc... should be avoided, (*28)

Why "Lazy Boy"

Because it likes REST, of course :), (*29)

The Versions

08/06 2018

dev-develop

dev-develop https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2018

2.6.0

2.6.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

22/08 2017

2.5.0

2.5.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

18/08 2017

2.4.0

2.4.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

17/08 2017

dev-add-default-debug

dev-add-default-debug https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

09/05 2017

dev-use-tags-for-commands

dev-use-tags-for-commands https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

09/03 2017

dev-master

9999999-dev https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

09/03 2017

2.2.3

2.2.3.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

09/03 2017

2.3.0

2.3.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

04/12 2016

dev-oliver-tweaks

dev-oliver-tweaks https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

18/05 2016

2.2.2

2.2.2.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

18/05 2016

dev-SilexUpdate

dev-SilexUpdate https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

25/04 2016

2.1.8

2.1.8.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

25/04 2016

2.2.1

2.2.1.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

11/04 2016

2.2.0

2.2.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

05/04 2016

2.1.7

2.1.7.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

05/04 2016

2.1.6

2.1.6.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

29/03 2016

2.1.5

2.1.5.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

23/03 2016

2.1.4

2.1.4.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

17/03 2016

2.1.3

2.1.3.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

16/03 2016

2.1.2

2.1.2.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

09/02 2016

2.1.1

2.1.1.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

19/01 2016

2.1.0

2.1.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

18/01 2016

2.0.7

2.0.7.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

05/01 2016

2.0.6

2.0.6.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

04/01 2016

2.0.5

2.0.5.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

15/12 2015

2.0.4

2.0.4.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

15/12 2015

2.0.3

2.0.3.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

15/12 2015

2.0.2

2.0.2.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

04/12 2015

2.0.1

2.0.1.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

20/11 2015

2.0.0

2.0.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

20/11 2015

dev-MovedToYamlDefaults

dev-MovedToYamlDefaults https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

20/11 2015

1.1.1

1.1.1.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

05/11 2015

1.1.0

1.1.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

MIT

The Requires

 

The Development Requires

05/11 2015

1.0.0

1.0.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

proprietary

The Requires

 

The Development Requires

05/11 2015

dev-yml-loader

dev-yml-loader https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

proprietary

The Requires

 

The Development Requires

19/08 2015

0.3.0

0.3.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

proprietary

The Requires

 

The Development Requires

19/05 2015

0.2.0

0.2.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

proprietary

The Requires

 

The Development Requires

16/02 2015

0.1.2

0.1.2.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

proprietary

The Requires

 

The Development Requires

03/02 2015

0.1.1

0.1.1.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

proprietary

The Requires

 

The Development Requires

02/02 2015

0.1.0

0.1.0.0 https://github.com/silktide/lazy-boy

A skeleton REST API application, using Silex and Syringe with support for Puzzle-DI

  Sources   Download

proprietary

The Requires

 

The Development Requires