title: Symfony3.2 to symfony4 security.encoder_factory deprecated error
body: <p>I updated my website from Symfony 3.2 to Symfony 4, by creating a new symfony4 skeleton and moved the source code from symfony3.2 to symfony4.</p>
  
  <p>I had been made the changes as mentioned in <a href="https://symfony.com/doc/current/setup/upgrade_major.html" rel="nofollow noreferrer">Upgrading Symfony4</a>.Also I installed all the required packages.Now I can make routing and successfully got my web page on the display,the problem I am facing is login form doesn't work.</p>
  
  <p>In my login controller for symfony3.2 version,</p>
  
  <p>I used security.encoder_factory service</p>
  
  <p>And when I am running it in symfony4 it results:</p>
  
  <p><code>The "security.encoder_factory" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.</code></p>
  
  <p>My controller code for encoding password is:</p>
  
  <pre><code>public function loginAction(Request $request)
  {
      #$defaultEncoder = new MessageDigestPasswordEncoder('bcrypt', true, 5000);
      $defaultEncoder = new MessageDigestPasswordEncoder('bcrypt');
  
      $encoders = [
          User::class =&gt; $defaultEncoder, // Your user class. This line specify you ant sha512 encoder for this user class
          ];
  
      $encoderFactory = new EncoderFactory($encoders);
  
      $data = [
          'error' =&gt; null,
          '_username' =&gt; null,
      ];
      if ($request-&gt;isMethod('POST')) {
          $_username = $request-&gt;request-&gt;get('_username');
          $_password = $request-&gt;request-&gt;get('_password');
  
          $data['_username'] = $_username;
          $user = $this-&gt;getDoctrine()-&gt;getManager()
              -&gt;getRepository("App:User")
              -&gt;findOneBy(array('username' =&gt; $_username);
          if (!$user) {
              $data['error']  = 'User-Id does not exist';
              return $this-&gt;render(
                  'login.html.twig',
                  $data
              );
          }
  
          $encoder = $encoderFactory-&gt;getEncoder($user);
          $salt = $user-&gt;getSalt();
          #$encoder = $this-&gt;encodePassword($_password, $salt);
  
          if (!$encoder-&gt;isPasswordValid($user-&gt;getPassword(), $encoder)) {
              $data['error'] = 'User-Id or Password not valid.';
              return $this-&gt;render(
                  'login.html.twig',
                  $data
              );
          } 
  
          return $this-&gt;redirect($this-&gt;generateUrl('default__home_page'));
      }
  
      return $this-&gt;render(
          'login.html.twig',
       $data
      );
  }
  </code></pre>
  
  <p>My security for encoding is:</p>
  
  <pre><code>security:
     encoders:
          App\Entity\User: bcrypt
          App\Security\User\WebserviceUser: bcrypt
          Symfony\Component\Security\Core\User\User: bcrypt
          FOS\UserBundle\Model\UserInterface: sha512
  # https://symfony.com/doc/current/security.html#where-do-users-come-from-    user-providers
      providers:
          #in_memory: { memory: ~ }
          our_db_provider:
              entity:
                  class: App:User
                  property: username
      fos_userbundle:
          id: fos_user.user_provider.username_email
  firewalls:
      dev:
          pattern: ^/(_(profiler|wdt)|css|images|js)/
          security: false
      secured_area:
          anonymous: ~
          pattern:    ^/s/login$
          http_basic: ~
          provider: fos_userbundle
          user_checker: security.user_checker
  
          form_login:
              login_path: login_page
              check_path: login_page
              failure_handler: security.authentication.failure_handler
          guard:
              authenticators:
                  - App\Security\LoginControllerAuthenticator
          # activate different ways to authenticate
  
          # http_basic: ~
          # http://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
  
          # form_login: ~
          # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
  
          logout:
              path:   /logout/
              target: /login/
  </code></pre>
  
  <p>Is there any alternative way or service to encoding my password as the above code represents.</p>
  
  <p>error:</p>
  
  <pre><code>No encoder has been configured for account "App\Entity\User".
  
    at vendor/symfony/security/Core/Encoder/EncoderFactory.php:51
    at Symfony\Component\Security\Core\Encoder\EncoderFactory-&gt;getEncoder(object(User))
       (src/Controller/Controller.php:65)
    at App\Controller\Controller-&gt;loginAction(object(Request))
       (vendor/symfony/http-kernel/HttpKernel.php:149)
    at Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(object(Request), 1)
       (vendor/symfony/http-kernel/HttpKernel.php:66)
    at Symfony\Component\HttpKernel\HttpKernel-&gt;handle(object(Request), 1, true)
       (vendor/symfony/http-kernel/Kernel.php:188)
    at Symfony\Component\HttpKernel\Kernel-&gt;handle(object(Request))
       (public/index.php:37)
  </code></pre>
  
  <p>Thanks in advance.</p>