symfonette / class-named-services
1.0.0
2016-07-08 21:04 UTC
Requires
- php: ^5.5|^7.0
- symfony/dependency-injection: ^2.8.5|^3.0.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.9
- phpunit/phpunit: ^4.8|^5.2
- sllh/php-cs-fixer-styleci-bridge: ^2.0
- symfony/config: ^2.8|^3.0
- symfony/http-kernel: ^2.8|^3.0
- symfony/var-dumper: ^2.8|^3.0
Suggests
- symfony/http-kernel: If you want to use bundle
This package is auto-updated.
Last update: 2024-12-05 03:54:24 UTC
README
All services can be accessed by FQCN.
Installation
This project can be installed via Composer:
composer require symfonette/class-named-services
Standalone
use Symfonette\ClassNamedServices\ContainerBuilderConfigurator; use Symfony\Component\DependencyInjection\ContainerBuilder; $builder = new ContainerBuilder(); $configurator = new ContainerBuilderConfigurator(); $configurator->configure($builder);
Symfony Bundle
use Symfonette\ClassNamedServices\Bundle\ClassNamedServiceBundle; use Symfony\Component\HttpKernel\Kernel; class AppKernel extends Kernel { public function registerBundles() { return [ // ... new ClassNamedServiceBundle, // ... ]; } }
Usage
In dependency injection definition:
# app/config/services.yml services: controller_main: class: AppBundle\Controller\MainController arguments: - '@Symfony\Bridge\Doctrine\RegistryInterface' - '@Twig_Environment'
In routing definition:
# app/config/routing.yml homepage: path: / defaults: _controller: AppBundle\Controller\MainController:homepage
In controller:
namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class ContactController extends Controller { public function formAction() { $validator = $this->get(Validator::class); // ... } }