Laravel和服务器有问题:
我创建了一个作业并在localhost中进行了测试,结果运行良好。
然后,我在服务器上传输它,得到一个错误:
未找到类“App/Jobs/JobName”。
我想是因为一些服务器设置。因为我在本地主机或其他项目(服务器)上没有同样的问题。
我在谷歌上找不到答案。也许有人能解决这个问题?
控制器:
use App\Jobs\PushNotification;
/* some logic */
$this->dispatch(new PushNotification($alarm,$receivers));
职务:
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 */
谢谢您!
最佳答案
也许这会有帮助:
在本地计算机的终端中执行composer dump-autoload
命令。
重新上载到有问题的服务器文件。
确保命名正确。你写的错误:Class "App/Jobs/JobName" not found.
,而且旅游类名是PushNotification
,我不确定这是否是你的目的。
在服务器上生成(我希望您也在服务器上生成以获取所有依赖项)
祝你好运!