Laravel. Job Class not found on server (linux)

There is some problem with Laravel and server:

I created a job and tested it in localhost and it worked fine.

Then, I transfer it on the server and got an error:

Class "App/Jobs/JobName" not found.

I suppose it because of some server settings. Because I didn't have the same problems on localhost or in another projects (servers).

I didn't find answer in google. Maybe someone can solve this?

Controller:

use App\Jobs\PushNotification; 
/* some logic */
$this->dispatch(new PushNotification($alarm,$receivers));

Job:

namespace App\Jobs;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;

class PushNotification implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/* some logic */

Thank you!

1 answer

  • answered 2018-04-24 10:38 Adam Kozlowski

    Maybe it will help:

    1. Execute the command composer dump-autoload in your local machine's terminal.
    2. Re-upload to server files that you have problem with.
    3. Make sure that naming is correct. You wrote error: Class "App/Jobs/JobName" not found., and tour class name is PushNotification, I am not sure if it was your aim.

    4. Make on server composer dump-autoload (i hope you make also composer update on server - to get the all dependencies)

    Good luck!