Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Curl Builder

Curl Builder Laravel Package

alexkart/curl-builder

Generate reproducible curl commands from PSR-7 ServerRequest instances or build them manually. Add, set, and override options (with or without arguments), set URLs, and output a ready-to-run curl string—useful for debugging HTTP requests and sharing examples.

View on GitHub
Deep Wiki
Context7

Curl command generator library

Frequently asked questions about Curl Builder
How do I use alexkart/curl-builder to debug failed API requests in Laravel?
Install the package via Composer, then use the `Command` class to generate curl commands from PSR-7 requests. For example, intercept failed requests in middleware and log the generated curl string for debugging. Pair it with Laravel’s `Log::debug()` to avoid cluttering production logs.
Can I generate curl commands manually without PSR-7 requests?
Yes. Use the fluent `Command` class to chain methods like `setUrl()`, `addOption()`, and `addOptions()` to build curl commands step-by-step. This is useful for testing or constructing complex requests like multipart/form-data without relying on existing HTTP clients.
Will this package work with Laravel’s built-in HTTP client or Guzzle?
It’s designed to complement both. For Guzzle, use middleware to convert requests/responses to curl strings. For Laravel’s HTTP client, extend it with a decorator or middleware to inject curl generation. The package is stateless, so it won’t interfere with existing clients.
How do I prevent curl commands from leaking sensitive data (e.g., API tokens) in production?
Use environment-based toggles (e.g., `APP_DEBUG`) to disable curl generation in production. For sensitive data, manually redact tokens or headers before logging. The package itself doesn’t handle redaction—pair it with Laravel’s `Str::mask()` or custom middleware for security.
Is alexkart/curl-builder suitable for logging HTTP interactions in Laravel?
Yes, but it’s lightweight and best used alongside Laravel’s logging (e.g., Monolog). Generate curl strings in debug mode and log them via `Log::debug()` or a custom channel. Avoid using it for high-volume logging, as it’s not optimized for performance-critical scenarios.
How do I integrate this into an Artisan command for CLI debugging?
Create a custom Artisan command that uses the `Command` class to generate curl for specific routes or failed requests. For example, extend Laravel’s `lastAttemptedRequest()` to output curl strings when a command like `php artisan curl:generate` is run.
Does this package support Laravel 10/11 and PHP 8.1+?
Yes, it’s fully compatible with Laravel 10/11 and PHP 8.1+. The package has no breaking changes and follows Laravel’s dependency requirements. Test it in your project’s environment to ensure edge cases (e.g., custom headers) work as expected.
What’s the performance impact of generating curl strings in production?
The overhead is negligible for individual requests, but generating curl strings for every request could impact performance if overused. Use environment-based checks (e.g., `if (app()->isLocal())`) to gate curl generation. For production, log only critical failures.
Are there alternatives to alexkart/curl-builder for debugging HTTP requests in Laravel?
Yes. For logging, consider `spatie/laravel-activitylog` or Laravel’s built-in `tap()` method. For curl generation, tools like `guzzlehttp/guzzle` (with middleware) or `php-curl` can be used manually. However, this package offers a dedicated, fluent API for curl-specific debugging.
How can I extend the package to support custom curl options or Laravel-specific features?
The package is open-source and MIT-licensed, so you can fork it and extend the `Command` class. For Laravel-specific features, create middleware or service providers to wrap the package. Submit pull requests to the repo if you’d like to contribute improvements for the community.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium