Я только что обновился с laravel 5.2 до laravel 5.3
В настоящее время у меня проблемы с Mailables.
Я всегда получаю ReflectionException
Class not found
, Странно то, что, когда я пытаюсь отправить почту напрямую (без очереди), никаких проблем не возникает.
Я просмотрел таблицу заданий в своей базе данных, так как я использую драйвер очередей базы данных. Но это не похоже на проблему.
Вот полная трассировка стека:
in Container.php line 734
at ReflectionClass->__construct('') in Container.php line 734
at Container->build('', array()) in Container.php line 629
at Container->make('', array()) in Application.php line 699
at Application->make('') in Job.php line 83
at Job->resolve('') in Job.php line 149
at Job->failed(object(ReflectionException)) in SyncQueue.php line 168
at SyncQueue->handleFailedJob(object(SyncJob), object(ReflectionException)) in SyncQueue.php line 65
at SyncQueue->handleSyncException(object(SyncJob), object(ReflectionException)) in SyncQueue.php line 46
at SyncQueue->push(object(SendQueuedMailable)) in Mailable.php line 138
at Mailable->queue(object(QueueManager)) in Mailer.php line 211
at Mailer->queue(object(OrderReceived)) in MailableMailer.php line 127
at MailableMailer->queue(object(OrderReceived)) in VisitorController.php line 302
at VisitorController->_flushToDatabase(array('firstName' => 'Jules', 'lastName' => 'test', 'email' => '[email protected]', 'subscribe' => 'true', 'printTicketsByOrganisation' => 'true', 'tickets' => array(array('priceId' => '5947ed599e6a4e19bba0d9b54cb8a471', 'price' => '15.00', 'category' => 'Standaardprijs', 'seat' => '267', 'amount' => '1'), array('priceId' => '49f91249bff343f09cf1a90b9dd5cc1d', 'price' => '5-5.00', 'category' => 'Kinderen (GRATIS)', 'seat' => '266', 'amount' => '1'))), object(Request)) in VisitorController.php line 261
at VisitorController->ajaxPersist(object(Request))
at call_user_func_array(array(object(VisitorController), 'ajaxPersist'), array(object(Request))) in Controller.php line 52
at Controller->callAction('ajaxPersist', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(VisitorController), 'ajaxPersist') in Route.php line 190
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TicketsAvailable.php line 25
at TicketsAvailable->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TicketsOpen.php line 29
at TicketsOpen->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 263
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/home/jules/sites/tickets/public/index.php') in server.php line 21
Мой почтовый класс:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Event;
use App\Visitor;
use App\Organisation;
class OrderReceived extends Mailable
{
use Queueable, SerializesModels;
private $visitor;
private $event;
private $organisation;
private $bankingCode;
/**
* Create a new message instance.
* @param App\Visitor $visitor The visitor who bought the tickets
* @param App\Event $event The event where the visitor bought tickets from
* @param App\Organisation $organisation The organisation that hosts the event
* @param string $bankingCode The formatted banking code the user should use for payement
* @return void
*/
public function __construct(Visitor $visitor, Event $event, Organisation $organisation, $bankingCode)
{
$this->visitor = $visitor;
$this->event = $event;
$this->organisation = $organisation;
$this->bankingCode;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.visitor.payementRequestEmail')
->subject(trans('messages.emailPayementRequest'))
->with([
'langCode' => \App::getLocale(),
'eventName' => $this->event->name,
'organisationName' => $this->organisation->name,
'name' => $this->visitor->firstName.' '.$this->visitor->lastName,
'bankAccount' => chunk_split($this->organisation->bankAccount,4,' '),//format to ISO 13616
'bankingCode' => $this->bankingCode,
'url' => $this->organisation->url,
'color' => $this->organisation->colorAsHex,
'ticketAmount' => $this->visitor->seats()->count(),
'totalPrice' => $this->visitor->calculateTotalPrice(),
'email' => $this->organisation->email,
'userEmail' => $this->visitor->email,
'printedByOrganisation' => $this->visitor->printTicketsByOrganisation,
]);
}
}
И наконец, звонок для отправки по электронной почте:
Mail::to($visitor->email)->queue(new OrderReceived($visitor, $event, $event->organisation()->first(), $humanBankingCode));
Что я делаю неправильно? Или это ошибка в Laravel?
После настройки параметров почты в config/mail.php
, используйте класс Mail в вашем контроллере и поместите код ниже
use Illuminate\Support\Facades\Mail;
или же
use Mail;
Затем выполните код. Это работает нормально для меня.
Других решений пока нет …