That is an error with your queue.
Check this out: http://laravel.io/forum/06-18-2014-errorexception-undefined-index-from-artisan-dump-autoload-problem-in-illuminateviewfactory
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
That is an error with your queue.
Check this out: http://laravel.io/forum/06-18-2014-errorexception-undefined-index-from-artisan-dump-autoload-problem-in-illuminateviewfactory
This is the new enquiry.blade.php.
<h1>We been contacted by.... </h1>
<p>
Name: {{ $name] }}<br>
Email address: {{ $email }} <br>
Subject: {{ $subject }}<br>
Message: {{ $msg }}<br>
Date: {{ $date }}<br>
User IP address: {{ $client_ip }}<br>
</p>
@Man are you sorted now? the data gets passed to the view correctly yes?
@karlos545 not yet, almost there. Just getting a new error when i run queue:work.
[ErrorException]
Undefined index: job
I am trying to figure out what is causing this error
The queue is being sent to my sqs queue service successfully, the queue:work is what the new issue is and I am trying to figure out why.
@Man Test with mail::send make sure all the changes work. Then we'll fix the queue issue.
Can you send me the Job class please @Man
@jekinney With mail::send I get an error:
syntax error, unexpected ']'
I also get this same error when the scheduler runs queue:work. this is my contact controller.php:
<?php
use Illuminate\Http\Request; // preferred Request Facade instead of Input;
use Carbon\Carbon; // Set the date in a carbon instance for flexibility.
use \Session as Session;
use \Redirect as Redirect;
use \Validator as Validator;
class ContactController extends Controller {
//Server Contact view:: we will create view in next step
public function getContact(){
return View::make('contact');
}
//Contact Form
public function getContactUsForm(Request $request){
$data = [
'name' => $request->get('name'),
'email' => $request->get('email'),
'subject' => $request->get('subject'),
'msg' => $request->get('msg'),
'date' => Carbon::now(),
'client_ip' => $request->getClientIp(),
];
//Validation rules Validate First less work if an error
$rules = array (
'name' => 'required',
'email' => 'required|email',
'subject' => 'required',
'msg' => 'required',
);
//Validate data
$validator = Validator::make ($data, $rules);
//If everything is correct then run passes.
if ($validator -> passes()){
//Send email using Laravel send function
Mail::send('enquiry', $data, function($msg) use ($data)
{
//email 'From' field: Get users email add and name
//email 'To' field: cahnge this to emails that you want to be notified.
$msg->to('my@email.com', 'Enquiry')->subject('contact request');
});
return Redirect::to('/')->with(array('note' => 'Thank you! Your message has been recieved.', 'note_type' => 'success') );
} // Don't need else statements as a return stops the script from continuing.
//return contact form with errors
return Redirect::to('/contact')->withErrors($validator);
}
}
and this is my enquire.blade.php:
<h1>We been contacted by.... </h1>
<p>
Name: {{ $name] }}<br>
Email address: {{ $email }} <br>
Subject: {{ $subject }}<br>
Message: {{ $msg }}<br>
Date: {{ $date }}<br>
User IP address: {{ $client_ip }}<br>
</p>
I don't know where the unexpected ']' is coming from.
It's in your view. Take a look at $name.
@thomaskim thanks. @jekinney the mail:send works. The queue still sends the error.
@karlos545 Is this the job class that you are referring to?
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
abstract class Job
{
/*
|--------------------------------------------------------------------------
| Queueable Jobs
|--------------------------------------------------------------------------
|
| This job base class provides a central location to place any logic that
| is shared across all of your jobs. The trait included with the class
| provides access to the "queueOn" and "delay" queue helper methods.
|
*/
use Queueable;
}
A new error is being thrown with the queue:work:
[ErrorException]
htmlentities() expects parameter 1 to be string, array given (View: /path/to/resources/views/enquiry.blade.php)
and:
[ErrorException]
htmlentities() expects parameter 1 to be string, array given
Yeah the htmlentities error is in the view. Change it back to the syntax I posted.
Put your queue driver to file and retest.
@jekinney Putting your syntax in the view file now throws out an error:
Undefined variable: data
how do i define the data variable in enquire.blade.php below?
<h1>We been contacted by.... </h1>
<p>
Name: {{ $data['name'] }}<br>
Email address: {{ $data['email'] }} <br>
Subject: {{ $data['subject'] }}<br>
Message: {{ $data['msg'] }}<br>
Date: {{ $data['date'] }}<br>
User IP address: {{ $data['client_ip'] }}<br>
</p>
@karlos545 , @jekinney - I have put the $data variable in the view file as well:
<?php
$data = [
'name' => $request->get('name'),
'email' => $request->get('email'),
'subject' => $request->get('subject'),
'msg' => $request->get('msg'),
'date' => Carbon::now(),
'client_ip' => $request->getClientIp(),
];
?>
<h1>Someone filled out the contact form... </h1>
<p>
Name: {{ $data['name'] }}<br>
Email address: {{ $data['email'] }} <br>
Subject: {{ $data['subject'] }}<br>
Message: {{ $data['msg'] }}<br>
Date: {{ $data['date'] }}<br>
User IP address: {{ $data['client_ip'] }}<br>
</p>
Now I have to define the $request variable. How can I do that in the view.blade.php file? Everything we have done so far works flawlessly when it is working straight internally, but when the queue gets sent out, executing it gets a little tricky.
@man You have been getting some exceptionally excellent one on one training over the past few nights. This would cost a fortune!!
@man you should subscribe to the site. Jeff is better than us to learn from...
@jimmck I agree, I have learned so much over the last 3 days, and believe it or not, it has been one problem, just has different layers. From creating a contact form, to scheduling a queue for that contact form. The solutions I have garnered has taught me so much about laravel, it's outstanding.
@karlos545 Jeff has taught me so much about the basics of starting up an app in laravel. I would love to subscribe, it is not in my budget at this time. I will definitely give back when I have the means.
@man So are you passing your $data array to your view? You don't need to actually insert it into the blade.
@jimmck it works without it normally, but it throws out errors when it is passed through the queue. The queue is treating the blade file like it's own controller. I don't know why.
@man How are you calling the view? A queue is just a data source.
@jimmck The route file calls out the controller:
Route::get('contact', 'ContactController@getContact');
Route::post('contact', 'ContactController@getContactUsForm');
The controller makes the contact form and sends it to the queue:
<?php
use Illuminate\Http\Request; // preferred Request Facade instead of Input;
use Carbon\Carbon; // Set the date in a carbon instance for flexibility.
use \Session as Session;
use \Redirect as Redirect;
use \Validator as Validator;
class ContactController extends Controller {
//Server Contact view:: we will create view in next step
public function getContact(){
return View::make('contact');
}
//Contact Form
public function getContactUsForm(Request $request){
$data = [
'name' => $request->get('name'),
'email' => $request->get('email'),
'subject' => $request->get('subject'),
'msg' => $request->get('msg'),
'date' => Carbon::now(),
'client_ip' => $request->getClientIp(),
];
//Validation rules Validate First less work if an error
$rules = array (
'name' => 'required',
'email' => 'required|email',
'subject' => 'required',
'msg' => 'required',
);
//Validate data
$validator = Validator::make ($data, $rules);
//If everything is correct then run passes.
if ($validator -> passes()){
//Send email using Laravel send function
Mail::queue('enquiry', $data, function($msg) use ($data)
{
//email 'From' field: Get users email add and name
//email 'To' field: cahnge this to emails that you want to be notified.
$msg->to('my@email.com', 'Enquiry')->subject('contact request');
});
return Redirect::to('/')->with(array('note' => 'Thank you! Your message has been recieved.', 'note_type' => 'success') );
} // Don't need else statements as a return stops the script from continuing.
//return contact form with errors
return Redirect::to('/contact')->withErrors($validator);
}
}
Everything works here. enquire.blade.php file:
<h1>Someone filled out the contact form... </h1>
<p>
Name: $name<br>
Email address: $email <br>
Subject: $subject<br>
Message: $msg<br>
Date: $date<br>
User IP address: $client_ip <br>
</p>
When I run queue:work, it treats the enquire.blade.php file as if it is on its own by throwing data variable errors. This only happens with the queue, other than that, everything will work as it is supposed to.
You need to read the View doc. How do you pass data into a view? More importantly how are you reading the data off the queue and passing it your view? A webpage and a queue can supply inputs back to the server. No data is being stripped. It is there waiting to be passed.
I followed this tutorial, http://laravelcoding.com/blog/laravel-5-beauty-sending-mail-and-using-queues#14-contact-us, The tutorial guided through using Requests and it worked very well with the queue. Thank everyone for helping me through this, I seriously learned so much more about laravel now through your help and through trail and error.
Glad you got it @Man great job!!
Please or to participate in this conversation.