PHPackages                             achrafsoltani/routing-service-provider - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. achrafsoltani/routing-service-provider

ActiveLibrary

achrafsoltani/routing-service-provider
======================================

Routing Service Provider for Silex

v1.0.4(10y ago)095MITPHPPHP &gt;=5.3.0

Since Jun 4Pushed 10y ago1 watchersCompare

[ Source](https://github.com/AchrafSoltani/RoutingServiceProvider)[ Packagist](https://packagist.org/packages/achrafsoltani/routing-service-provider)[ Docs](http://www.achrafsoltani.com)[ RSS](/packages/achrafsoltani-routing-service-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

RoutingServiceProvider
======================

[](#routingserviceprovider)

Convention-based controllers for Silex

[![Latest Stable Version](https://camo.githubusercontent.com/29e6e1c375333f693280622b61904f97cef0382e5cb3d633a284291ba3378cc9/68747470733a2f2f706f7365722e707567782e6f72672f616368726166736f6c74616e692f726f7574696e672d736572766963652d70726f76696465722f762f737461626c65)](https://packagist.org/packages/achrafsoltani/routing-service-provider)[![Total Downloads](https://camo.githubusercontent.com/e1114b4892b2cb3e837563add1349506c020b6a1ba9198561a74e57a483ea4e9/68747470733a2f2f706f7365722e707567782e6f72672f616368726166736f6c74616e692f726f7574696e672d736572766963652d70726f76696465722f646f776e6c6f616473)](https://packagist.org/packages/achrafsoltani/routing-service-provider)[![License](https://camo.githubusercontent.com/24b82257fc411f9f1ed96500a161b5fb161e9382bf2b8a10bca698a5f780a524/68747470733a2f2f706f7365722e707567782e6f72672f616368726166736f6c74616e692f726f7574696e672d736572766963652d70726f76696465722f6c6963656e7365)](https://packagist.org/packages/achrafsoltani/routing-service-provider)

Requirements
------------

[](#requirements)

- PHP 5.3+
- monolog/monolog (through the MonologServiceProvider)

Installation
------------

[](#installation)

```
$ composer require achrafsoltani/routing-service-provider
```

Setup
-----

[](#setup)

```
$loader = require_once __DIR__.'/vendor/autoload.php';
// THIS LINE IS MANDATORY, SO THE AUTOLOAD BECOMES AWARE OF YOUR CUSTOM CONTROLLERS
$loader->addPsr4('',__DIR__.'/src/',true);

use Silex\Application;
use AchrafSoltani\Provider\RoutingServiceProvider;
use Symfony\Component\HttpFoundation\Response;

$app = new Application();
$app['debug'] = true;

// Registering
$app->register(new RoutingServiceProvider());

// Defining routes
// You could also implement a custom routes loader from different locations and server a RouteCollection
// instance throough : $app['routing']->addRoutes($routes, $prefix);
$route = new Symfony\Component\Routing\Route('/', array('controller' => 'Foo\Controller\MainController::index'));
// setting methods is optional
$route->setMethods(array('GET', 'POST'));

$route2 = new Symfony\Component\Routing\Route('/hello', array('controller' => 'Foo\Controller\MainController::hello'));

$app['routing']->addRoute('home', $route);
$app['routing']->addRoute('hello', $route2);

// call this rigth before $app->run();
$app['routing']->route();
$app->run();

```

Example Controller
------------------

[](#example-controller)

```
