David Nguyen
David Nguyen

Follow

David Nguyen

Follow

cURL Converter - A tool convert cURL commands to Laravel's HTTP Client

David Nguyen's photo
David Nguyen
·Jan 9, 2023·

1 min read

Play this article

Last week Shift released the cURL Converter. It allows you to quickly convert curl requests to an Http client request. Now all those example API calls you find within documentation can actually be used for your Laravel apps.

For example, take the following curl example from Fathom.

curl https://api.usefathom.com/v1/account
    -H "Authorization: Bearer API_TOKEN_HERE"

Shift's cURL Converter outputs its equivalent Http request:

Http::withToken('API_TOKEN_HERE')
    ->get('https://api.usefathom.com/v1/account');

The underlying code for Shift's cURL Converter is available as a package on GitHub. This package provides an artisan command which wraps curl, allowing you to convert requests to Http code from the command line.

For convenience, Shift also has an online version of the tool. This allows you to quickly paste and convert curl requests. No need to install a Composer package.

If you’re interested in the development of this tool, JMac (Jason McCreary), the creator of Shift, live streamed coding it. You may also check out the laravel-shift/curl-converter repo to review its code or contribute.

Source:

 
Share this