- Notifications
You must be signed in to change notification settings - Fork3
Laravel HTTP Request to Curl Command
License
jigar-dhulla/laravel-http-to-curl
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This package has two use-cases:
- Simple dump and die with curl command for local development for troubleshooting the http request.
- Enable logging curl command for each request in the logs.
You can pull in the package via composer:
composer require jigarakatidus/laravel-http-to-curl
The package will automatically register itself
Http::ddWithCurl() ->get('https://example.com/api/resource');
Outputs
curl -H'User-Agent: GuzzleHttp/7' -X'GET''https://example.com/api/resource'
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¶m2=value2'
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"}'
To enable the automatic logging of curl command for each request, configure these options directly through environment variables:
HTTP_TO_CURL_LOGGING
: Enable/disable logging (defaults to false)HTTP_TO_CURL_LOG_LEVEL
: Set log level (defaults to "debug")HTTP_TO_CURL_LOG_CHANNEL
: Select log channel (defaults to "stack")
Optionally, you can publish the configuration file using the following command:
php artisan vendor:publish --tag=http-to-curl-config
This will create aconfig/http-to-curl.php
file where you can customize the logging behavior.
When you enable logging by settingHTTP_TO_CURL_LOGGING=true
in your environment, all HTTP requests will be automatically logged. For example, if your application makes this request:
Http::post('https://api.example.com/users', ['name' =>'John Doe','email' =>'john@example.com']);
This cURL command will be automatically logged to your configured log channel:
[2025-05-13 23:53:46] local.DEBUG: curl -H 'User-Agent: GuzzleHttp/7' -H 'Content-Type: application/json' -X 'POST' 'https://api.example.com/users' -d '{"name":"John Doe","email":"john@example.com"}'
This is useful for debugging API calls in both development and production environments.
Please seeCHANGELOG for more information what has changed recently.
$ composertest
Pull Requests are welcome.
If you've found a bug regarding security please mailjigar.tidus@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please seeLicense File for more information.
About
Laravel HTTP Request to Curl Command
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.