Level 2
Please show your ApiRequest::curlRequest method
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a command class that is sending data to an external site and I want to validate the output from the curl request. So it's not my endpoint that I can test with a curl -o command. What options do I have to execute the class and see that the data is actually getting generated for $request_data below?
I am doing this because my logging isn't generating an error or confirmation so I need to see where this command is failing.
public function handle()
{
Log::info('Attempting to post deliveries');
$users = User::all();
foreach ($users as $user)
{
Auth::loginUsingId($user->id);
$getswift_key = auth()->user()->getMerchantGetswiftKey();
if (is_null($getswift_key))
{
Log::info("getswift order sync: this merchant ".auth()->user()->email. " not have the getswift key");
continue;
}
$order_headers = OrderHeader::query()->where(function ($q){
$q->whereNull('getswift_status')->orWhere('getswift_status' , OrderHeader::DELIVERY_NEW);
})->orderByDesc('id')->get();
foreach ($order_headers as $order_header)
{
if (\Carbon\Carbon::parse($order_header->creation_date)->lessThan(Carbon::now()->addMonth()))
continue;
$url = config('getswift.base_url').config('getswift.deliveries');
$request_data = $this->mappingGetswiftFeilds($order_header , $getswift_key);
list($response , $httpcode) = ApiRequest::curlRequest($url , $request_data);
echo "response code ". $httpcode ." ";
if ($httpcode != 200 && isset($response->message))
{
Log::error('getswift order sync: order_number: '.$order_header->order_number.' -----message:---- '.$response->message);
continue;
}
$order_header->getswift_status = OrderHeader::DELIVERY_ADDED;
if ($order_header->save())
{
Log::info('getswift order sync: order_number: '.$order_header->order_number.' -----message:---- : posted successfully');
}
}
Auth::logout();
}
}
I ended up using var_dump and it worked for what I needed.
Please or to participate in this conversation.