2017 © Pedro Peláez
 

library silex-controller-provider

Controller provider for silex applications

image

flaviojr/silex-controller-provider

Controller provider for silex applications

  • Monday, July 24, 2017
  • by flaviojr
  • Repository
  • 1 Watchers
  • 3 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

silex-controller-provider

Controller provider for silex, (*1)

What is this?

This provider contains the logic to load your controllers dynamically, registering them in you Silex Applications. With this, you no longer needs to manually register each one of your controllers, passing their respective dependencies., (*2)

Usage

To install it:, (*3)

$ composer require "flaviojr/silex-controller-provider":"1.0"

To use this provider, you simply need to register it within your application:, (*4)

//Don't forget to register this provider first
$app->register(new Silex\Provider\ServiceControllerServiceProvider);

$app->register(new Sneek\Providers\ControllerProvider('controller-dir', 'Your-root-namespace'[, 'your-namespace-mirror']));
  • The first parameter indicate where your controller files are.
  • The second one is the root namespace from where your controllers are. For example, if your controller namespace is App\Controllers\HomeController, then the value to be passed is the string 'App'.
  • The last parameter is optional, you should use it if your root namespace isn't the name of your root directory. For example, if you have a folder structure like this: src/Controllers/CoffeeController, having the namespace App\Controllers\CoffeeController you have to pass the 'src' string, so that the provider know that 'src' is equivalent to 'App' in this case.

Using the registered controllers

The provider register your controllers using their namespaces as index. To access they in your routes, you just need to pass their namespace followed by the method you are trying to access., (*5)

$app->get('/', 'App\Controllers\CoffeeController:index');

Notes

  • You don't have to worry about your controller dependencies, the provider will recursively resolve each one of them.

The Versions

24/07 2017

dev-master

9999999-dev

Controller provider for silex applications

  Sources   Download

MIT

The Requires

 

by Flávio Jr.

24/07 2017

v1.0

1.0.0.0

Controller provider for silex applications

  Sources   Download

MIT

The Requires

 

by Flávio Jr.