Naming and Format
Place service classes inside src/YourBundle/Utils/. Let the service container create new service objects for you via configuration:
# app/config/config.yml services: my_testservice: class: MyApp\MyBundle\MyTestService arguments: [myargument] |
An instance of the MyApp\MyBundle\MyTestService object is now available via the service container. The container is available in any traditional Symfony controller where you can access the services of the container via the get() shortcut method:
$myTestService = $this->get('my_testservice'); $myTestService->myFunction($myArgument); |