Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

saxulum-legacy/saxulum-controller-provider

Repository files navigation

saxulum controller provider

works with plain silex-php

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality

Features

  • Register Controllers as a Service with container, __construct and method injection
  • register their actions over a static method within the controller

Requirements

  • php >=5.3
  • silex/silex ~1.0

Installation

The ServiceControllerServiceProvider from silex itself is needed!

$app->register(new ServiceControllerServiceProvider());
$app->register(new SaxulumControllerProvider());

Usage

The example controllers ContainerExampleController and ServiceExampleController they implement ControllerRouteInterface

public static function addRoutes(Application $app, $serviceId)
{
    $app
        ->get('/container', $serviceId . ':indexAction')
        ->bind('container_index')
    ;
}
$app['controller.map']
    ->addController()
        ->setNamespace('Saxulum\SaxulumControllerProvider\Controller\ContainerExampleController')
        ->setServiceId('saxulum.saxulumcontrollerprovider.controller.containerinjectcontroller')
        ->setInjectContainer(true)
    ->end()
    ->addController()
        ->setNamespace('Saxulum\SaxulumControllerProvider\Controller\ServiceExampleController')
        ->setServiceId('saxulum.saxulumcontrollerprovider.controller.serviceController')
        ->setInjectionKeys(array('test.data'))
        ->addMethod()
            ->setName('setTestData1')
            ->setInjectionKeys(array('test.data'))
        ->end()
        ->addMethod()
            ->setName('setTestData2')
            ->setInjectionKeys(array('test.data'))
        ->end()
    ->end()
;

About

A simple controller provider for saxulum (silex)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages