简体   繁体   中英

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!

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM