Skip to content

jigar-dhulla/laravel-http-to-curl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel HTTP to Curl

Simple tool to dump the raw curl command from Laravel HTTP Request.

Installation

You can pull in the package via composer:

composer require --dev jigarakatidus/laravel-http-to-curl

The package will automatically register itself

Usage

Basic GET Request

Http::ddWithCurl()
    ->get('https://example.com/api/resource');

Outputs

curl -H 'User-Agent: GuzzleHttp/7' -X 'GET' 'https://example.com/api/resource'

GET Request with Query Parameters

Http::ddWithCurl()
    ->get('https://example.com/api/resource', [
        'param1' => 'value1',
        'param2' => 'value2',
    ]);

Outputs

curl -H 'User-Agent: GuzzleHttp/7' -X 'GET' 'https://example.com/api/resource?param1=value1&param2=value2'

POST Request with JSON Payload

Http::ddWithCurl()
    ->acceptJson()
    ->post('https://example.com/api/resource', [
        'key1' => 'value1',
        'key2' => 'value2',
    ]);

Outputs

curl -H 'User-Agent: GuzzleHttp/7' -H 'Accept: application/json' -H 'Content-Type: application/json' -X 'POST' 'https://example.com/api/resource' -d '{"key1":"value1","key2":"value2"}'

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Pull Requests are welcome.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.