Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用队列的Laravel中的问题_Php_Laravel - Fatal编程技术网

Php 使用队列的Laravel中的问题

Php 使用队列的Laravel中的问题,php,laravel,Php,Laravel,我有一些问题,直到现在我还不能解决。当我执行php artisan queue:work时,我遇到了下一个错误: [2019-09-22 23:25:20][12]处理:App\Listeners\WelcomeNewsStudentListener [2019-09-22 23:25:20][12]失败:App\Listeners\WelcomeNewsStudentListener 在我的.env文件下面: APP_NAME=Laravel APP_ENV=local APP_KEY=bas

我有一些问题,直到现在我还不能解决。当我执行
php artisan queue:work
时,我遇到了下一个错误:

[2019-09-22 23:25:20][12]处理:App\Listeners\WelcomeNewsStudentListener

[2019-09-22 23:25:20][12]失败:App\Listeners\WelcomeNewsStudentListener

在我的
.env
文件下面:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:i+VBlcoP1fQodPn+ZV9os2knWv/piI4Gb/TDr0Dmq9U=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=crudAlumnos
DB_USERNAME=root
DB_PASSWORD=12345

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
在我的
EventServiceProvider.php
中,我有下一个:

<?php

    namespace App\Providers;

    use App\Events\NewStudentHasRegisteredEvent;
    //use App\Listeners\WelcomeNewStudentListener;
    use App\Listeners\RegisterStudentToNewsletter;
    //use App\Listeners\NotifyAdminViaSlack;
    use Illuminate\Support\Facades\Event;
    use Illuminate\Auth\Events\Registered;
    use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
    use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

    class EventServiceProvider extends ServiceProvider
    {
        /**
         * The event listener mappings for the application.
         *
         * @var array
         */
        protected $listen = [
            //agregando mi evento
            NewStudentHasRegisteredEvent::class => [
                //aqui se agrega el listener
                \App\Listeners\WelcomeNewStudentListener::class,
                RegisterStudentToNewsletter::class,
                \App\Listeners\NotifyAdminViaSlack::class,
            ],
        ];

        /**
         * Register any events for your application.
         *
         * @return void
         */
        public function boot()
        {
            parent::boot();

            //
        }
    }
此外,我的数据库中还有作业和
失败的\u作业


因此,我无法使用队列:工作

解决此问题。您的邮件配置不完整,因此
邮件
外观引发异常。您的意思是什么?在这个例子中,我没有输入邮件的密码和用户名,但实际上我有它,只是我不想把它放在这里
<?php

namespace App\Listeners;

use App\Mail\WelcomeNewUserMail;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Mail;

class WelcomeNewStudentListener implements ShouldQueue
{

//ESTE ES EL LISTENER
    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        //
        sleep(10); //10 seconds

        Mail::to($event->datosEnviar->email)->send(new WelcomeNewUserMail());
    }
}