title: Laravel 5.1 illuminate/queue capsule error 'Class encrypter does not exist'
body: <p>I have the need to push jobs on a queue from outside the Laravel framework. Found the queue capsule manager that should make this possible:</p>
  
  <p><a href="https://github.com/illuminate/queue" rel="nofollow">https://github.com/illuminate/queue</a></p>
  
  <p>Trying the following as per their example code:</p>
  
  <pre><code>&lt;?php
  
  require_once __DIR__ . '/../../bootstrap/autoload.php';
  
  use Illuminate\Queue\Capsule\Manager as Queue;
  
  $queue = new Queue;
  
  $queue-&gt;addConnection([
      'driver' =&gt; 'sync',
  ]);
  
  $queue-&gt;setAsGlobal();
  
  $queue-&gt;push(function($job)
  {
      echo "test!\n";
      $job-&gt;delete();
  });
  </code></pre>
  
  <p>Running this code results in the following error:</p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Class encrypter does not exist' in vendor/laravel/framework/src/Illuminate/Container/Container.php:741
  Stack trace:
  #0 vendor/laravel/framework/src/Illuminate/Container/Container.php(741): ReflectionClass-&gt;__construct('encrypter')
  #1 vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container-&gt;build('encrypter', Array)
  #2 vendor/laravel/framework/src/Illuminate/Container/Container.php(1163): Illuminate\Container\Container-&gt;make('encrypter')
  #3 vendor/laravel/framework/src/Illuminate/Queue/QueueManager.php(117): Illuminate\Container\Container-&gt;offsetGet('encrypter')
  #4 vendor/laravel/framework/src/Illuminate/Queue/Capsule/Manager.php(135): Illuminate\Queue\QueueM in vendor/laravel/framework/src/Illuminate/Container/Container.php on line 741
  
  Fatal error: Uncaught exception 'ReflectionException' with message 'Class encrypter does not exist' in vendor/laravel/framework/src/Illuminate/Container/Container.php:741
  Stack trace:
  #0 vendor/laravel/framework/src/Illuminate/Container/Container.php(741): ReflectionClass-&gt;__construct('encrypter')
  #1 vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container-&gt;build('encrypter', Array)
  #2 vendor/laravel/framework/src/Illuminate/Container/Container.php(1163): Illuminate\Container\Container-&gt;make('encrypter')
  #3 vendor/laravel/framework/src/Illuminate/Queue/QueueManager.php(117): Illuminate\Container\Container-&gt;offsetGet('encrypter')
  #4 vendor/laravel/framework/src/Illuminate/Queue/Capsule/Manager.php(135): Illuminate\Queue\QueueM in vendor/laravel/framework/src/Illuminate/Container/Container.php on line 741
  </code></pre>
  
  <p>Searching on this subject I found something that said to add the following code:</p>
  
  <pre><code>$queue-&gt;getContainer()-&gt;bind('encrypter', function() {
      return new Illuminate\Encryption\Encrypter('nInrMfTMQngxqRvoFpjstYjZX0qH1Nlr', 'AES-256-CBC');
  });
  $queue-&gt;getContainer()-&gt;bind('request', function() {
      return new Illuminate\Http\Request();
  });
  </code></pre>
  
  <p>Which does not seem to be a solution, because I then get the following error:</p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Target [Illuminate\Contracts\Encryption\Encrypter] is not instantiable.' in vendor/laravel/framework/src/Illuminate/Container/Container.php:749
  Stack trace:
  #0 vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container-&gt;build('Illuminate\\Cont...', Array)
  #1 vendor/laravel/framework/src/Illuminate/Container/Container.php(842): Illuminate\Container\Container-&gt;make('Illuminate\\Cont...')
  #2 vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container-&gt;resolveClass(Object(ReflectionParameter))
  #3 vendor/laravel/framework/src/Illuminate/Container/Container.php(776): Illuminate\Container\Container-&gt;getDependencies(Array, Array)
  #4  in vendor/laravel/framework/src/Illuminate/Container/Container.php on line 749
  </code></pre>
  
  <p>Binding those should not be needed though, judging by the documentation from illuminate/queue. </p>
  
  <p>This occurs with laravel 5.1.27. Any thoughts/solutions?</p>
  
  <p>Update: I have tried it in a 4.2 environment, there I also have to bind the encrypter class, but doing that there works. (Does not give the not instantiable error)</p>