Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sys32's avatar
Level 3

Sent arguments to Job

I am working with jobs currently to speed up my panel.

I am trying to create a simple job to handle the API call, in the job I have a curl setup that takes a table in form of arguments to handle.

Error: Missing argument 1 for App\Jobs\runAPI::handle()

Controller sends this: 
        $args = [
            "action" => "action",
            "action2" => "action2",
        ];

dispatch(new runAPI($args)); <--- This has the argument for the call.

The job has this, obviously it has more than this but thats beyond whats needed.

    public function handle($args)
    {
            foreach ($args as $key => $value) {
                # take all arguments from the call, and convert to something the API can understand.
                $postfields[$key] = $value;
            }
}

For some reason the arguments, are not sent when i dispatch the job.

0 likes
1 reply
Sys32's avatar
Sys32
OP
Best Answer
Level 3

Resolved.

    protected $args;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($args)
    {
        $this->args = $args;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $args = $this->args;
    }

Please or to participate in this conversation.