HasHttpRequest) and config/array utilities align with Laravel’s modular, trait-driven architecture, enabling reusable cross-cutting concerns without bloating core logic. Ideal for shared services (e.g., API clients, data transformers) in microservices or monolithic apps.Illuminate\Pipeline, enabling reusable middleware-like workflows (e.g., request validation, logging, or data processing chains). Reduces boilerplate for complex business logic.Arr, Str) or alternative packages (e.g., spatie/array).HasHttpRequest can be mixed into Laravel models/services via Service Provider bindings or class mixins, extending functionality without inheritance.Log facade or a third-party logger.Http client).HasHttpRequest) could lead to method name collisions or unintended side effects in large codebases.HasHttpRequest trait replace Laravel’s Http client or augment it? If the latter, how will conflicts be managed?spatie/array).Arr, Str, Pipeline) or packages like spatie/array achieve the same goals with lower risk?Log facade).spatie/array, Laravel’s Arr helpers).yansongda/supports to composer.json and test array/config utilities in isolation (e.g., in a single service or helper class).HasHttpRequest) into Form Requests, Services, or Controllers.// app/Providers/AppServiceProvider.php
use Yansongda\Supports\Traits\HasHttpRequest;
class AppServiceProvider extends ServiceProvider {
public function boot() {
// Option 1: Mixin trait to a class
\App\Services\ApiClient::mixin(new HasHttpRequest());
// Option 2: Bind trait to container (advanced)
$this->app->bind(ApiClient::class, function ($app) {
$client = new ApiClient();
$client->mixin(new HasHttpRequest());
return $client;
});
}
}
Pipeline class (if it provides unique value over Laravel’s native Pipeline).use Yansongda\Supports\Pipeline;
$result = Pipeline::send($request)
->through([
function ($passable) { return $passable->validate(); },
function ($passable) { return $passable->log(); },
])
->then(function ($passable) { return $passable->process(); });
Log facade.// Before (removed in package)
$logger = new \Yansongda\Supports\Logger\StdoutHandler();
// After
\Log::info('Message');
| Feature | Compatibility | Workaround |
|---|---|---|
| PHP 8.0+ | ✅ Laravel 9+ compatible | Downgrade PHP for Laravel 8.x (not recommended) |
| Guzzle 7.x | ✅ Laravel 9+ uses Guzzle 7.x | Downgrade Guzzle or use facade wrapper |
| Array/Config Utilities | ✅ Works with Laravel’s Arr helpers; evaluate overlap with spatie/array |
Use selectively or replace with Spatie |
HasHttpRequest Trait |
⚠️ Not Laravel-native → requires manual integration | Bind to container or use Facade |
| Pipeline Support | ✅ Compatible with Laravel’s Pipeline |
Direct integration possible |
| Removed Logger | ❌ Breaking if app relied on it | Replace with \Log:: facade |
| Trait Method Conflicts | ⚠️ Risk of collisions with Laravel classes | Rename traits or use aliases |
composer.json and update config/app.php.How can I help you explore Laravel packages today?