Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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 |队列失败:App\Jobs\SendCollectionSMS缺少参数1:_Php_Laravel_Parameters_Constructor_Laravel 5.4 - Fatal编程技术网

Php Laravel |队列失败:App\Jobs\SendCollectionSMS缺少参数1:

Php Laravel |队列失败:App\Jobs\SendCollectionSMS缺少参数1:,php,laravel,parameters,constructor,laravel-5.4,Php,Laravel,Parameters,Constructor,Laravel 5.4,由于这个奇怪的错误,我所有的工作都失败了,我无法找出这里的问题所在 作业: { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; /** * Create a new job instance. * * @return void */ public $fName, $lName, $colAmt, $colDate, $totalAmt, $balAmt, $dueDate, $mobile_no, $

由于这个奇怪的错误,我所有的工作都失败了,我无法找出这里的问题所在

作业

{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
 * Create a new job instance.
 *
 * @return void
 */
public $fName, $lName, $colAmt, $colDate, $totalAmt, $balAmt, $dueDate, $mobile_no, $is_loan_complete;

public function __construct($fName, $lName, $colAmt, $colDate, $totalAmt, $balAmt, $dueDate, $mobile_no, $is_loan_complete)
{
    //
    $this->fName = $fName;
    $this->lName = $lName;
    $this->colAmt = $colAmt;
    $this->colDate = $colDate;
    $this->totalAmt = $totalAmt;
    $this->balAmt = $balAmt;
    $this->dueDate = $dueDate;
    $this->mobile_no = $mobile_no;
    $this->is_loan_complete = $is_loan_complete;
}

/**
 * Execute the job.
 *
 * @return void
 */
public function handle($fName, $lName, $colAmt, $colDate, $totalAmt, $balAmt, $dueDate, $mobile_no, $is_loan_complete)
{
    //

            $username = "xxxxxxxxxx";
        $hash = "xxxxxxxxxxxxxxxxxxxxxxxxx";

        // Config variables. Consult http://api.textlocal.in/docs for more info.
        $test = "0";

        // Data for text message. This is the text message data.
        $sender = "xxxxx"; // This is who the message appears to be from.
        $numbers = $mobile_no; // A single number or a comma-seperated list of numbers

        $message = "Dear ".$fName." ".$lName.", your payment of Rs. ".$colAmt." has been received on ".$colDate.".
    Total: Rs. ".$totalAmt.", Balance: ".$balAmt.", Due Date: ".$dueDate.". Thank You";
        // 612 chars or less
        // A single number or a comma-seperated list of numbers
        $message = urlencode($message);

        $data = "username=".$username."&hash=".$hash."&message=".$message."&sender=".$sender."&numbers=".$numbers."&test=".$test;
        $ch = curl_init('http://api.textlocal.in/send/?');
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        echo $result = curl_exec($ch); // This is the result from the API
        curl_close($ch);
        $this->pusher($result); 


}
从failed_jobs表中的错误中,我注意到由于参数错误,handle函数甚至没有运行

引发异常:

exception 'ErrorException' with message 'Missing argument 1 for App\Jobs\SendCollectionSMS::handle()' in C:\xampp\htdocs\financetest1\app\Jobs\SendCollectionSMS.php:42
Stack trace:
#0 C:\xampp\htdocs\financetest1\app\Jobs\SendCollectionSMS.php(42): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Missing argumen...', 'C:\\xampp\\htdocs...', 42, Array)
#1 [internal function]: App\Jobs\SendCollectionSMS->handle()
#2 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(30): call_user_func_array(Array, Array)
#3 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#4 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#5 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Container\Container.php(531): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#6 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#7 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(App\Jobs\SendCollectionSMS))
#8 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(App\Jobs\SendCollectionSMS))
#9 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#10 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(43): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\SendCollectionSMS), NULL)
#11 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(69): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#12 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(291): Illuminate\Queue\Jobs\Job->fire()
#13 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(258): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#14 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(110): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#15 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#16 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#17 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#18 C:\xampp\htdocs\financetest1\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(30): call_user_func_array(Array, Array)
我是从一个控制器那里打电话给这个工作的,比如:(很抱歉下面的代码太乱了,但它可以工作)

现在我确信在我的控制器中创建新作业时传递的参数是正确的,但我在处理程序中引用变量的方式似乎存在问题


这里出了什么问题?

这是一篇非常古老的帖子,但对于遇到这个问题的人来说

句柄函数不需要任何变量

public function handle()
在此函数中,您可以通过如下方式调用变量来获取变量:

$this->fName
如果仍然遇到“缺少参数1”问题:重新启动artisan命令

php artisan queue:work

我花了一段时间才弄明白,如果队列:工作已在运行,则更改作业文件无效。

您从何处调用此方法?@B.Desai请查看我的编辑
php artisan queue:work