Service

What is a Service?

A service Show archive.org snapshot is a discrete unit of functionality:

  1. It logically represents a business activity with a specified outcome.
  2. It is self-contained.
  3. It is a black box for its consumers.
  4. It may consist of other underlying services.

Put simply, a service is any PHP object that performs some sort of global task.

You don't have to do anything special to make a service: simply write a PHP class with some code that accomplishes a specific task.

In Symfony, all services live within a service container.

What is a Service Container? Show archive.org snapshot

A service container (or dependency injection container) is simply a PHP object that manages the instantiation of services (i.e. objects). It's analogue to Mage::getSingleton(). The idea is to construct the service object only when it's required to save memory and to speed up the application.

List the Services

List all the services:

[kiat@reporting misoro]$ sudo -u nginx php bin/console debug:container

Symfony Container Public Services
=================================

 --------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------
  Service ID                                                                              Class name             
 --------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------
  Symfony\Bundle\FrameworkBundle\Controller\RedirectController                            Symfony\Bundle\FrameworkBundle\Controller\RedirectController
  Symfony\Bundle\FrameworkBundle\Controller\TemplateController                            Symfony\Bundle\FrameworkBundle\Controller\TemplateController
  cache.app                                                                               Symfony\Component\Cache\Adapter\TraceableAdapter
  cache.app_clearer                                                                       alias for "cache.default_clearer"

But it's more useful to search for particular services:

[kiat@reporting misoro]$ sudo -u nginx php bin/console debug:container dbug

 Select one of the following services to display its information [dbug.util.file]:
  [0] dbug.util.file
 >


Information for Service "dbug.util.file"
========================================

 ---------------- ----------------------
  Option           Value
 ---------------- ----------------------
  Service ID       dbug.util.file
  Class            DbugBundle\Util\File
  Tags             -
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- ----------------------

Create a Service Without Autowiring

The 4 steps are:

1. Define the service in services.yml

src\DbugBundle\Resources\config\services.yml

services:
    dbug.util.file:
        class: DbugBundle\Util\File
        public: true # false by default, which will log the following

[2019-04-03 09:10:49] php.INFO: User Deprecated: The "dbug.util.file" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The "dbug.util.file" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. at /usr/share/nginx/html/misoro/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:282)"} []

2. Load the file in DependencyInjection

src\DbugBundle\DependencyInjection\DbugExtension.php

The name of the class and file is constructed from the name of the registered bundle replacing the postfix Bundle with Extension. For our example, the file name is src\DbugBundle\DbugBundle.php, so the class name is DbugExtension.

<?php
namespace DbugBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class DbugExtension extends Extension
{
    /**
     * {@inheritDoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.yml');
    }
}
[kiat@reporting misoro]$ sudo -u nginx php bin/console config:dump-reference

Available registered bundles with their extension alias if available
====================================================================

 --------------------------------- ------------------------------
  Bundle name                       Extension alias
 --------------------------------- ------------------------------
  AkeneoBatchBundle                 akeneo_batch
  DbugBundle                        dbug
  ...
  StarsEmgsiheDbBundle              stars_emgsihe_db
  StarsEntityExtendBundle
  StarsLoggerEventBundle
  StofDoctrineExtensionsBundle      stof_doctrine_extensions
  SwiftmailerBundle                 swiftmailer
  TwigBundle                        twig
  WebProfilerBundle                 web_profiler
  WebServerBundle                   web_server
 --------------------------------- ------------------------------

 // Provide the name of a bundle as the first argument of this command to dump
 // its default configuration. (e.g. config:dump-reference
 // FrameworkBundle)
 //
 // For dumping a specific option, add its path as the second argument of this
 // command. (e.g. config:dump-reference FrameworkBundle
 // profiler.matcher to dump the
 // framework.profiler.matcher configuration)

3. Create the Service Class

src\DbugBundle\Util\File.php

<?php
namespace DbugBundle\Util;

class File
{
    /**
     * Read last lines of file    
     * https://gist.github.com/lorenzos/1711e81a9162320fde20
     * 
     */
    public function tail(string $filepath, int $lines = 1, bool $adaptive = true): string 
    {
        // Open file
        $f = @fopen($filepath, "rb");
        if ($f === false) return 'invalid path: '.$filepath; //false;
        // Sets buffer size
        if (!$adaptive) $buffer = 4096;
        else $buffer = ($lines < 2 ? 64 : ($lines < 10 ? 512 : 4096));
        // Jump to last character
        fseek($f, -1, SEEK_END);
        // Read it and adjust line number if necessary
        // (Otherwise the result would be wrong if file doesn't end with a blank line)
        if (fread($f, 1) != "\n") $lines -= 1;
        
        // Start reading
        $output = '';
        $chunk = '';
        // While we would like more
        while (ftell($f) > 0 && $lines >= 0) {
            // Figure out how far back we should jump
            $seek = min(ftell($f), $buffer);
            // Do the jump (backwards, relative to where we are)
            fseek($f, -$seek, SEEK_CUR);
            // Read a chunk and prepend it to our output
            $output = ($chunk = fread($f, $seek)) . $output;
            // Jump back to where we started reading
            fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
            // Decrease our line counter
            $lines -= substr_count($chunk, "\n");
        }
        // While we have too many lines
        // (Because of buffer size we might have read too many)
        while ($lines++ < 0) {
            // Find first newline and remove all text before that
            $output = substr($output, strpos($output, "\n") + 1);
        }
        // Close file and return
        fclose($f);
        return trim($output);
    }
}

4. Clear the Cache

[kiat@reporting misoro]$ sudo -u nginx php bin/console cache:clear

 // Clearing the cache for the dev environment with debug
 // true

Clear production cache:

[kiat@reporting misoro]$ sudo rm -rf var/cache/prod/*
[kiat@reporting misoro]$ sudo -u nginx php bin/console cache:clear -e prod

 // Clearing the cache for the prod environment with debug
 // false


 [OK] Cache for the "prod" environment (debug=false) was successfully cleared.

For

PHP Fatal error: Cannot declare class ZendDebug, because the name is already in use in /usr/share/nginx/html/misoro/src/DbugBundle/Util/ZendDebug.php

can be fixed by declaring namespace DbugBundle\Util; in the file ZendDebug.php.

Fetching a Service in Controller with Container

This method is not recommended for future compatibility of Symfony. See blog Show archive.org snapshot :

So, should we deprecate the possibility to inject the service_container entirely alongside with ContainerAware*? That's a possibility that the community might consider when preparing Symfony 5.

<?php
namespace DbugBundle\Controller;

use Oro\Bundle\SecurityBundle\Annotation\Acl;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

//use DbugBundle\Util\File as DbugFile;

/**
 * @Route("/dbug")
 */
class DbugController extends Controller
{
    // extends Controller to expose get container method: $this->get('service_name')

    //...

    /**
     * @Route(
     *  "/tail/{lines}/{filename}",
     *  name="dbug_tail",
     *  defaults={"filename"="dev.log"},
     *  requirements={"filename"=".+"}
     * )
     * @Acl(
     *     id="dbug_tail",
     *     type="action",
     *     label="Dbug tailAction"
     * )
     */
    public function tailAction($lines, $filename): Response
    {
        $path = $filename[0] == '/'
            ? $this->get('kernel')->getProjectDir() . $filename
            : $this->get('kernel')->getProjectDir() . '/var/logs/' . $filename;
        $output = $this->get('dbug.util.file')->tail($path, $lines ?: 20);
        $output = "<h3>$path <em>last $lines lines</em></h3><pre>".print_r($output, true).'</pre>';
        return new Response('<html><body>'.$output.'</body></html>');
    }
}

Create a Service with Autowiring

In this blog Show archive.org snapshot , it states

using the container directly is not considered a good practice

and

Slowly but steadily, we're now ready to move away from having any need to inject the container in user-land classes. That's why in Symfony 3.4 services and aliases will be private by default. This means that even if you manage to have the container, you will not be able to get() them anymore by default. Instead, you should use regular dependency injection.

To create an autowiring service, we have the same 4 steps as above, except that we need to define the service like this:

Define the service in services.yml

src\DbugBundle\Resources\config\services.yml

services:
    DbugBundle\Util\File:
        autowire: true

    DbugBundle\Controller\DbugController:
        tags: ['controller.service_arguments']

As noted above that services and aliases will be private by default, and in here Show archive.org snapshot

The autowiring system looks for a service whose id exactly matches the type-hint

So, we do not use alias for an autowiring service.

[kiat@reporting misoro]$ sudo -u nginx php bin/console debug:container dbug

 Select one of the following services to display its information:
  [0] DbugBundle\Util\File
  [1] DbugBundle\Controller\DbugController
 > 0


Information for Service "DbugBundle\Util\File"
==============================================

 ---------------- ----------------------
  Option           Value
 ---------------- ----------------------
  Service ID       DbugBundle\Util\File
  Class            DbugBundle\Util\File
  Tags             -
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        yes
  Autoconfigured   no
 ---------------- ----------------------

[kiat@reporting misoro]$ sudo -u nginx php bin/console debug:container dbug

 Select one of the following services to display its information:
  [0] DbugBundle\Util\File
  [1] DbugBundle\Controller\DbugController
 > 1


Information for Service "DbugBundle\Controller\DbugController"
==============================================================

 ---------------- --------------------------------------
  Option           Value
 ---------------- --------------------------------------
  Service ID       DbugBundle\Controller\DbugController
  Class            DbugBundle\Controller\DbugController
  Tags             controller.service_arguments
  Public           yes
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- --------------------------------------

Fetching an Autowiring Service in Controller

In services.yml for autowiring, I have defined the controller as a service. In Symfony 3.4 Show archive.org snapshot :

In Symfony 3.3, controllers are services by default.

and

controllers are imported separately to make sure they're public and have a tag that allows actions to type-hint services

The tag is tags: ['controller.service_arguments'].

<?php
namespace DbugBundle\Controller;

use Oro\Bundle\SecurityBundle\Annotation\Acl;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;

use DbugBundle\Util\File as DbugFile;

/**
 * @Route("/dbug")
 */
class DbugController
{
    //...

    /**
     * @Route(
     *  "/tail/{lines}/{filename}",
     *  name="dbug_tail",
     *  defaults={"lines"=20, "filename"="dev.log"},
     *  requirements={"filename"=".+"}
     * )
     * @Acl(
     *     id="dbug_tail",
     *     type="action",
     *     label="Dbug tailAction"
     * )
     */
    public function tailAction($lines, $filename, DbugFile $file, KernelInterface $kernel): Response
    {
        $path = $filename[0] == '/'
            ? $kernel->getProjectDir() . $filename
            : $kernel->getProjectDir() . '/var/logs/' . $filename;
        $lines = $lines ?: 20;
        $output = $file->tail($path, $lines);
        $output = "<h3>$path <em>last $lines lines</em></h3><pre>".print_r($output, true).'</pre>';
        return new Response('<html><body>'.$output.'</body></html>');
    }
}

RuntimeException: Either the argument is nullable and no null value has been provided

Runtime exception in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php (line 78):

Controller "Stars\Bundle\LoggerEventBundle\Controller\CommandController::insertAction()" requires that you provide a value for the "$kernel" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.

That is due to missing configuration on defining the controller as a service or missing the tag tags: ['controller.service_arguments'] in the controller service.

Add this in services.yml or other yml file to fix the error:

services:
    Stars\Bundle\LoggerEventBundle\Controller\CommandController:
        tags: ['controller.service_arguments']

Once added, refresh the browser (no need for cache warming) and the error should go away.

List of Autowiring Services

[kiat@reporting misoro]$ sudo -u nginx php bin/console debug:autowiring

Autowirable Services
====================

 The following classes & interfaces can be used as type-hints when autowiring:

 ------------------------------------------------------------------------------------
  DbugBundle\Controller\DbugController                                          
  DbugBundle\Util\File                                                          
  Doctrine\Common\Annotations\Reader                                            
      alias to annotations.cached_reader                                        
  Doctrine\Common\Persistence\ManagerRegistry                                   
      alias to doctrine                                                         
  Doctrine\Common\Persistence\ObjectManager                                     
      alias to doctrine.orm.default_entity_manager                              
  Doctrine\DBAL\Connection                                                      
      alias to doctrine.dbal.default_connection                                 
  Doctrine\DBAL\Driver\Connection                                               
      alias to doctrine.dbal.default_connection                                 
  Doctrine\ORM\EntityManagerInterface                                           
      alias to doctrine.orm.default_entity_manager                              
  JMS\Serializer\ArrayTransformerInterface                                      
      alias to jms_serializer.serializer                                        
  JMS\Serializer\SerializerInterface                                            
      alias to jms_serializer.serializer                                        
  Knp\Menu\FactoryInterface                                                     
      alias to knp_menu.factory                                                 
  Knp\Menu\Matcher\MatcherInterface                                             
      alias to knp_menu.matcher                                                 
  Knp\Menu\Util\MenuManipulator                                                 
      alias to knp_menu.manipulator                                             
  Lexik\Bundle\MaintenanceBundle\Command\DriverLockCommand                      
  Lexik\Bundle\MaintenanceBundle\Command\DriverUnlockCommand                    
  Oro\Bundle\ActionBundle\Command\DebugActionCommand                            
  Oro\Bundle\ActionBundle\Command\DebugConditionCommand                         
  Oro\Bundle\ActionBundle\Command\DebugOperationCommand                         
  Oro\Bundle\ActionBundle\Command\ValidateActionConfigurationCommand            
  Oro\Bundle\ApiBundle\Command\CacheClearCommand                                
  Oro\Bundle\ApiBundle\Command\DebugCommand                                     
  Oro\Bundle\ApiBundle\Command\DocCacheClearCommand                             
  Oro\Bundle\ApiBundle\Command\DumpCommand                                      
  Oro\Bundle\ApiBundle\Command\DumpConfigCommand                                
  Oro\Bundle\ApiBundle\Command\DumpConfigReferenceCommand                       
  Oro\Bundle\ApiBundle\Command\DumpMetadataCommand                              
  Oro\Bundle\AssetBundle\Command\OroAssetsBuildCommand                          
  Oro\Bundle\AssetBundle\Command\OroAssetsInstallCommand                        
  Oro\Bundle\BatchBundle\Command\CleanupCommand                                 
  Oro\Bundle\CacheBundle\Command\InvalidateCacheScheduleCommand                 
  Oro\Bundle\ConfigBundle\Command\ConfigUpdateCommand                           
  Oro\Bundle\CronBundle\Command\CronCommand                                     
  Oro\Bundle\CronBundle\Command\CronDefinitionsLoadCommand                      
  Oro\Bundle\DistributionBundle\Command\InstallPackageCommand                   
  Oro\Bundle\DistributionBundle\Command\ListAvailablePackagesCommand            
  Oro\Bundle\DistributionBundle\Command\ListInstalledPackagesCommand            
  Oro\Bundle\DistributionBundle\Command\ListUpdatesCommand                      
  Oro\Bundle\DistributionBundle\Command\UpdatePackageCommand                    
  Oro\Bundle\EmailBundle\Command\Cron\EmailBodySyncCommand                      
  Oro\Bundle\EmailBundle\Command\UpdateAssociationsCommand                      
  Oro\Bundle\EntityBundle\Command\EntityAliasDebugCommand                       
  Oro\Bundle\EntityConfigBundle\Command\CacheClearCommand                       
  Oro\Bundle\EntityConfigBundle\Command\CacheWarmupCommand                      
  Oro\Bundle\EntityConfigBundle\Command\DebugCommand                            
  Oro\Bundle\EntityConfigBundle\Command\UpdateCommand                           
  Oro\Bundle\EntityExtendBundle\Command\CacheCheckCommand                       
  Oro\Bundle\EntityExtendBundle\Command\CacheClearCommand                       
  Oro\Bundle\EntityExtendBundle\Command\CacheWarmupCommand                      
  Oro\Bundle\EntityExtendBundle\Command\MigrationUpdateConfigCommand            
  Oro\Bundle\EntityExtendBundle\Command\RouterCacheClearCommand                 
  Oro\Bundle\EntityExtendBundle\Command\UpdateConfigCommand                     
  Oro\Bundle\EntityExtendBundle\Command\UpdateSchemaCommand                     
  Oro\Bundle\ImapBundle\Command\Cron\EmailSyncCommand                           
  Oro\Bundle\ImapBundle\Command\Cron\SendCredentialNotificationsCommand         
  Oro\Bundle\ImportExportBundle\Command\ImportCommand                           
  Oro\Bundle\ImportExportBundle\Command\ImportCommand\Cron\CleanupStorageCommand
  Oro\Bundle\InstallerBundle\Command\CheckRequirementsCommand                   
  Oro\Bundle\InstallerBundle\Command\InstallCommand                             
  Oro\Bundle\InstallerBundle\Command\LoadPackageDemoDataCommand                 
  Oro\Bundle\InstallerBundle\Command\PlatformUpdateCommand                      
  Oro\Bundle\InstallerBundle\Command\RunScriptsCommand                          
  Oro\Bundle\IntegrationBundle\Command\CleanupCommand                           
  Oro\Bundle\IntegrationBundle\Command\SyncCommand                              
  Oro\Bundle\LayoutBundle\Command\DebugCommand                                  
  Oro\Bundle\LocaleBundle\Command\OroLocalizationDumpCommand                    
  Oro\Bundle\LocaleBundle\Command\UpdatelocalizationCommand                     
  Oro\Bundle\LoggerBundle\Command\LoggerEmailNotificationCommand                
  Oro\Bundle\LoggerBundle\Command\LoggerLevelCommand                            
  Oro\Bundle\MessageQueueBundle\Command\CleanupCommand                          
  Oro\Bundle\MessageQueueBundle\Command\ClientConsumeMessagesCommand            
  Oro\Bundle\MessageQueueBundle\Command\ConsumerHeartbeatCommand                
  Oro\Bundle\MessageQueueBundle\Command\TransportConsumeMessagesCommand         
  Oro\Bundle\MigrationBundle\Command\DumpMigrationsCommand                      
  Oro\Bundle\MigrationBundle\Command\LoadDataFixturesCommand                    
  Oro\Bundle\MigrationBundle\Command\LoadMigrationsCommand                      
  Oro\Bundle\NavigationBundle\Command\ClearNavigationHistoryCommand             
  Oro\Bundle\NavigationBundle\Command\ResetMenuUpdatesCommand                   
  Oro\Bundle\NotificationBundle\Command\MassNotificationCommand                 
  Oro\Bundle\OrganizationBundle\Command\UpdateOrganizationCommand               
  Oro\Bundle\PlatformBundle\Command\HelpCommand                                 
  Oro\Bundle\PlatformBundle\Command\OptionalListenersCommand                    
  Oro\Bundle\ReminderBundle\Command\SendRemindersCommand                        
  Oro\Bundle\ReportBundle\Command\CalendarDateCommand                           
  Oro\Bundle\RequireJSBundle\Command\OroBuildCommand                            
  Oro\Bundle\SearchBundle\Command\IndexCommand                                  
  Oro\Bundle\SearchBundle\Command\ReindexCommand                                
  Oro\Bundle\SecurityBundle\Command\LoadConfigurablePermissionCommand           
  Oro\Bundle\SecurityBundle\Command\LoadPermissionConfigurationCommand          
  Oro\Bundle\TestGeneratorBundle\Command\CreateTestCommand                      
  Oro\Bundle\ThemeBundle\Command\ThemeCommand                                   
  Oro\Bundle\TranslationBundle\Command\OroLanguageUpdateCommand                 
  Oro\Bundle\TranslationBundle\Command\OroTranslationDumpCommand                
  Oro\Bundle\TranslationBundle\Command\OroTranslationLoadCommand                
  Oro\Bundle\TranslationBundle\Command\OroTranslationPackCommand                
  Oro\Bundle\TranslationBundle\Command\OroTranslationResetCommand               
  Oro\Bundle\UserBundle\Command\CreateUserCommand                               
  Oro\Bundle\UserBundle\Command\GenerateWSSEHeaderCommand                       
  Oro\Bundle\UserBundle\Command\ImpersonateUserCommand                          
  Oro\Bundle\UserBundle\Command\ListUserCommand                                 
  Oro\Bundle\UserBundle\Command\UpdateUserCommand                               
  Oro\Bundle\WorkflowBundle\Command\DebugWorkflowDefinitionsCommand             
  Oro\Bundle\WorkflowBundle\Command\DumpWorkflowTranslationsCommand             
  Oro\Bundle\WorkflowBundle\Command\HandleProcessTriggerCommand                 
  Oro\Bundle\WorkflowBundle\Command\HandleTransitionCronTriggerCommand          
  Oro\Bundle\WorkflowBundle\Command\LoadProcessConfigurationCommand             
  Oro\Bundle\WorkflowBundle\Command\LoadWorkflowDefinitionsCommand              
  Oro\Bundle\WorkflowBundle\Command\WorkflowTransitCommand                      
  Psr\Cache\CacheItemPoolInterface                                              
      alias to cache.app                                                        
  Psr\Container\ContainerInterface                                              
      alias to service_container                                                
  Psr\Log\LoggerInterface                                                       
      alias to monolog.logger                                                   
  SessionHandlerInterface                                                       
      alias to session.handler.native_file                                      
  Swift_Mailer                                                                  
      alias to swiftmailer.mailer.default                                       
  Swift_Spool                                                                   
      alias to swiftmailer.mailer.default.spool.memory                          
  Swift_Transport                                                               
      alias to swiftmailer.mailer.default.transport.spool                       
  Symfony\Bridge\Doctrine\RegistryInterface                                     
      alias to doctrine                                                         
  Symfony\Bundle\FrameworkBundle\Controller\RedirectController                  
  Symfony\Bundle\FrameworkBundle\Controller\TemplateController                  
  Symfony\Bundle\FrameworkBundle\Templating\EngineInterface                     
      alias to templating.engine.delegating                                     
  Symfony\Component\Asset\Packages                                              
      alias to assets.packages                                                  
  Symfony\Component\Cache\Adapter\AdapterInterface                              
      alias to cache.app                                                        
  Symfony\Component\DependencyInjection\ContainerInterface                      
      alias to service_container                                                
  Symfony\Component\EventDispatcher\EventDispatcherInterface                    
      alias to debug.event_dispatcher                                           
  Symfony\Component\Filesystem\Filesystem                                       
      alias to filesystem                                                       
  Symfony\Component\Form\FormFactoryInterface                                   
      alias to form.factory                                                     
  Symfony\Component\Form\FormRegistryInterface                                  
      alias to form.registry                                                    
  Symfony\Component\Form\ResolvedFormTypeFactoryInterface                       
      alias to oro_api.form.resolved_type_factory                               
  Symfony\Component\HttpFoundation\RequestStack                                 
      alias to request_stack                                                    
  Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface              
      alias to session.flash_bag                                                
  Symfony\Component\HttpFoundation\Session\SessionInterface                     
      alias to session                                                          
  Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface      
      alias to session.storage.native                                           
  Symfony\Component\HttpKernel\Config\FileLocator                               
      alias to file_locator                                                     
  Symfony\Component\HttpKernel\Debug\FileLinkFormatter                          
      alias to debug.file_link_formatter                                        
  Symfony\Component\HttpKernel\HttpKernelInterface                              
      alias to http_kernel                                                      
  Symfony\Component\HttpKernel\KernelInterface                                  
      alias to kernel                                                           
  Symfony\Component\PropertyAccess\PropertyAccessorInterface                    
      alias to property_accessor                                                
  Symfony\Component\Routing\Generator\UrlGeneratorInterface                     
      alias to router.default                                                   
  Symfony\Component\Routing\Matcher\UrlMatcherInterface                         
      alias to router.default                                                   
  Symfony\Component\Routing\RequestContext                                      
      alias to router.request_context                                           
  Symfony\Component\Routing\RequestContextAwareInterface                        
      alias to router.default                                                   
  Symfony\Component\Routing\RouterInterface                                     
      alias to router.default                                                   
  Symfony\Component\Security\Acl\Model\AclProviderInterface                     
      alias to oro_security.acl.dbal.provider                                   
  Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface 
      alias to security.authentication.manager                                  
  Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
      alias to security.token_storage                                           
  Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface  
      alias to debug.security.access.decision_manager                           
  Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface   
      alias to oro_security.authorization_checker                               
  Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface               
      alias to security.encoder_factory.generic                                 
  Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface          
      alias to security.user_password_encoder.generic                           
  Symfony\Component\Security\Core\Security                                      
      alias to security.helper                                                  
  Symfony\Component\Security\Core\User\UserCheckerInterface                     
      alias to security.user_checker                                            
  Symfony\Component\Security\Csrf\CsrfTokenManagerInterface                     
      alias to security.csrf.token_manager                                      
  Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface        
      alias to security.csrf.token_generator                                    
  Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface            
      alias to oro_embedded_form.csrf_token_storage.decorator                   
  Symfony\Component\Security\Guard\GuardAuthenticatorHandler                    
      alias to security.authentication.guard_handler                            
  Symfony\Component\Security\Http\Authentication\AuthenticationUtils            
      alias to security.authentication_utils                                    
  Symfony\Component\Security\Http\Firewall                                      
      alias to debug.security.firewall                                          
  Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface
      alias to security.authentication.session_strategy                         
  Symfony\Component\Serializer\Encoder\DecoderInterface                         
      alias to jms_serializer.serializer                                        
  Symfony\Component\Serializer\Encoder\EncoderInterface                         
      alias to jms_serializer.serializer                                        
  Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface    
      alias to serializer.mapping.class_metadata_factory                        
  Symfony\Component\Serializer\Normalizer\DenormalizerInterface                 
      alias to jms_serializer.serializer                                        
  Symfony\Component\Serializer\Normalizer\NormalizerInterface                   
      alias to jms_serializer.serializer                                        
  Symfony\Component\Serializer\Normalizer\ObjectNormalizer                      
      alias to serializer.normalizer.object                                     
  Symfony\Component\Serializer\SerializerInterface                              
      alias to jms_serializer.serializer                                        
  Symfony\Component\Stopwatch\Stopwatch                                         
      alias to debug.stopwatch                                                  
  Symfony\Component\Templating\EngineInterface                                  
      alias to templating.engine.delegating                                     
  Symfony\Component\Translation\TranslatorInterface                             
      alias to translator.data_collector                                        
  Symfony\Component\Validator\Validator\ValidatorInterface                      
      alias to debug.validator                                                  
  Twig\Environment                                                              
      alias to twig                                                             
  Twig_Environment                                                              
      alias to twig                                                             
 ------------------------------------------------------------------------------------

Define Commands as Services

OroPlatform depends on Symfony 3.4. See doc Show archive.org snapshot . Also see Add a Cron Job.

kiatng About 5 years ago