Framework: [5.2] - InvalidArgumentException - No handler registered for command [App\Jobs\TestJob]

Created on 29 Aug 2016  路  7Comments  路  Source: laravel/framework

I did not upgrade from 5.1 to 5.2, though it still seems that I am getting this error as well on v5.2.45.

I do have Illuminate\Bus\BusServiceProvider::class, in my app.php file.

InvalidArgumentException \vendor\laravelcollective\bus\src\Dispatcher.php:348
No handler registered for command [App\Jobs\TestJob]

I have attempted to call the job in multiple different ways.

$queue = Queue::later(\Carbon\Carbon::now()->addMinutes(1), (new \App\Jobs\TestJob(\Carbon\Carbon::now())));
$job = (new \App\Jobs\TestJob(\Carbon\Carbon::now()))->delay(10);
$queue = dispatch($job);

All attempts result in the same exception and fail.

[2016-08-29 09:22:22] Failed: App\Jobs\TestJob

My TestJob.php:

<?php

namespace App\Jobs;

use Carbon\Carbon;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Mail;

class TestJob extends Job implements ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    /**
     * @var Carbon
     */
    protected $date_scheduled;

    /**
     * Create a new job instance.
     *
     * @param Carbon $date_scheduled
     */
    public function __construct(Carbon $date_scheduled)
    {
        $this->date_scheduled = $date_scheduled;
    }

    /**
     * Execute the job.
     */
    public function handle()
    {
        $scheduled = $this->date_scheduled->format(DATE_RFC3339);
        $fired = Carbon::now()->format(DATE_RFC3339);
        Mail::raw("Scheduled at {$scheduled} and job fired at {$fired}", function ($m) {
            $m->from('[email protected]', 'Test');
            $m->to('[email protected]', 'Dak');
            $m->subject('TEST');
        });
    }
}

Replaced e-mail addresses for privacy reasons.

As you can see, it has a handle() method. I saw in the stack trace to confirm that it is looking for the handle() method.

// \vendor\laravelcollective\bus\src\Dispatcher.php:200 Collective\Bus\Dispatcher::Collective\Bus\{closure}
return $this->container->call([$command, 'handle']);

I just can't seem to figure out what is wrong. :disappointed:

Please help :cry:

All 7 comments

We've removed the ability to have non-self handling commands in L5.2. This was partially restored in 5.3 though.

Please run composer show -i.

I see... Okay, I will look over the 5.2 docs again.

Edit: I looked over the docs again. I do not see what I am doing wrong in comparison to the docs at https://laravel.com/docs/5.2/queues

Here is composer show -i as requested

aftership/aftership-php-sdk           5.0.9              The PHP SDK of AfterShip API
barryvdh/laravel-cors                 v0.8.2             Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application
barryvdh/laravel-dompdf               v0.6.1             A DOMPDF Wrapper for Laravel
bugsnag/bugsnag                       v3.3.0             Official Bugsnag notifier for PHP applications.
bugsnag/bugsnag-laravel               v2.3.0             Official Bugsnag notifier for Laravel applications.
bugsnag/bugsnag-psr-logger            v1.1.0             Official Bugsnag PHP PSR Logger.
chumper/zipper                        0.6.1              This is a little neat helper for the ZipArchive methods with handy functions
classpreloader/classpreloader         3.0.0              Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case
composer/ca-bundle                    1.0.3              Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.
dnoegel/php-xdg-base-dir              0.1                implementation of xdg base directory specification for php
doctrine/annotations                  v1.2.7             Docblock Annotations Parser
doctrine/cache                        v1.6.0             Caching library offering an object-oriented API for many cache backends
doctrine/collections                  v1.3.0             Collections Abstraction library
doctrine/common                       v2.6.1             Common Library for Doctrine projects
doctrine/dbal                         v2.5.4             Database Abstraction Layer
doctrine/inflector                    v1.1.0             Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                 1.0.5              A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                        v1.0.1             Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
dompdf/dompdf                         v0.6.2             DOMPDF is a CSS 2.1 compliant HTML to PDF converter
drewm/mailchimp-api                   v2.2.4             Super-simple, minimum abstraction MailChimp API v3 wrapper
fabpot/goutte                         v3.1.2             A simple PHP Web Scraper
fzaninotto/faker                      v1.6.0             Faker is a PHP library that generates fake data for you.
guzzle/guzzle                         v3.9.3             PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle
guzzlehttp/guzzle                     6.2.1              Guzzle is a PHP HTTP client library
guzzlehttp/promises                   1.2.0              Guzzle promises library
guzzlehttp/psr7                       1.3.1              PSR-7 message implementation
hamcrest/hamcrest-php                 v1.2.2             This is the PHP port of Hamcrest Matchers
intervention/image                    2.3.7              Image handling and manipulation library with support for Laravel integration
ircmaxell/random-lib                  v1.1.0             A Library For Generating Secure Random Numbers
ircmaxell/security-lib                1.0.0              A Base Security Library
jakub-onderka/php-console-color       0.1
jakub-onderka/php-console-highlighter v0.3.2
jeremeamia/SuperClosure               2.2.0              Serialize Closure objects, including their context and binding
laravel/framework                     v5.2.45            The Laravel Framework.
laravelbook/ardent                    v3.4.2             Self-validating smart models for Laravel 5's Eloquent ORM
laravelcollective/bus                 v5.2               The Laravel Bus (5.1) package for use in Laravel 5.2.
laravelcollective/html                v5.2.4             HTML and Form Builders for the Laravel Framework
laurentbrieu/tcpdf                    dev-master 1352a46 Composer wrapper for TCPDF PHP library
league/flysystem                      1.0.27             Filesystem abstraction: Many filesystems, one API.
league/fractal                        0.14.0             Handle the output of complex data structures ready for API output.
league/oauth2-client                  1.4.2              OAuth 2.0 Client Library
maatwebsite/excel                     2.1.4              An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel
mandrill/mandrill                     1.0.55             API client library for the Mandrill email as a service platform
mannysoft/surveymonkey                dev-master e93d747 PHP class for SurveyMonkey API.
mockery/mockery                       0.9.5              Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succ...
monolog/monolog                       1.21.0             Sends your logs to files, sockets, inboxes, databases and various web services
mtdowling/cron-expression             v1.1.0             CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
nesbot/carbon                         1.21.0             A simple API extension for DateTime.
nikic/php-parser                      v2.1.0             A PHP parser written in PHP
pacely/mailchimp-apiv3                dev-master 859943e Simple API wrapper for Mailchimp API V3
paragonie/random_compat               v1.4.1             PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phenx/php-font-lib                    0.2.2              A library to read, parse, export and make subsets of different types of font files.
phpdocumentor/reflection-common       1.0                Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock     3.1.0              With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
phpdocumentor/type-resolver           0.2
phpoffice/phpexcel                    1.8.1              PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
phpspec/prophecy                      v1.6.1             Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage             2.2.4              Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator             1.4.1              FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template             1.2.1              Simple template engine.
phpunit/php-timer                     1.0.8              Utility class for timing
phpunit/php-token-stream              1.4.8              Wrapper around PHP's tokenizer extension.
phpunit/phpunit                       4.8.27             The PHP Unit Testing framework.
phpunit/phpunit-mock-objects          2.3.8              Mock Object library for PHPUnit
psr/http-message                      1.0.1              Common interface for HTTP messages
psr/log                               1.0.0              Common interface for logging libraries
psy/psysh                             v0.7.2             An interactive shell for modern PHP.
sebastian/comparator                  1.2.0              Provides the functionality to compare PHP values for equality
sebastian/diff                        1.4.1              Diff implementation
sebastian/environment                 1.3.8              Provides functionality to handle HHVM/PHP environments
sebastian/exporter                    1.2.2              Provides the functionality to export PHP variables for visualization
sebastian/global-state                1.1.1              Snapshotting of global state
sebastian/recursion-context           1.0.2              Provides functionality to recursively process PHP variables
sebastian/version                     1.0.6              Library that helps with managing the version number of Git-hosted PHP projects
swiftmailer/swiftmailer               v5.4.3             Swiftmailer, free feature-rich PHP mailer
symfony/browser-kit                   v3.1.3             Symfony BrowserKit Component
symfony/console                       v3.0.9             Symfony Console Component
symfony/css-selector                  v3.0.9             Symfony CssSelector Component
symfony/debug                         v3.0.9             Symfony Debug Component
symfony/dom-crawler                   v3.0.9             Symfony DomCrawler Component
symfony/event-dispatcher              v2.8.9             Symfony EventDispatcher Component
symfony/finder                        v3.0.9             Symfony Finder Component
symfony/http-foundation               v3.0.9             Symfony HttpFoundation Component
symfony/http-kernel                   v3.0.9             Symfony HttpKernel Component
symfony/polyfill-mbstring             v1.2.0             Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                v1.2.0             Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-util                 v1.2.0             Symfony utilities for portability of PHP codes
symfony/process                       v3.0.9             Symfony Process Component
symfony/routing                       v3.0.9             Symfony Routing Component
symfony/translation                   v3.0.9             Symfony Translation Component
symfony/var-dumper                    v3.0.9             Symfony mechanism for exploring and dumping PHP variables
symfony/yaml                          v3.1.3             Symfony Yaml Component
tijsverkoyen/css-to-inline-styles     1.5.5              CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.
vlucas/phpdotenv                      v2.3.0             Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
weblee/mandrill                       dev-master 809dedb Laravel 5 Mandrill API Wrapper
webmozart/assert                      1.1.0              Assertions to validate method input/output with nice error messages.
yajra/laravel-datatables-oracle       v6.17.0            jQuery DataTables API for Laravel 4|5

This bug will be related to the collective package. Nothing to do with laravel.

You could just use 1.x of this package: https://github.com/AltThree/Bus/tree/v1.1.0. I know it works. I wrote it and use it myself.

v2 of that package works with L5.3 too.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

klimentLambevski picture klimentLambevski  路  3Comments

kerbylav picture kerbylav  路  3Comments

CupOfTea696 picture CupOfTea696  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments

JamborJan picture JamborJan  路  3Comments