code-rhapsodie/get-url-contents-ez-twig-bundle
laravelcollective/html or tightenco/ziggy bridges) but requires explicit integration.curl-based approach.Http client or packages like spatie/array-to-xml/guzzlehttp/guzzle for more robust HTTP handling.curl without:
curl calls block the request lifecycle, risking timeouts in high-load scenarios.Http::get() (Laravel 8+) or Guzzle replace this with better error handling, retries, and middleware?Http client) be preferable for long-term viability?Http client, mimicking the bundle’s functionality but with modern safeguards.get_url_contents usages in Twig/eZ templates.Http client to replicate the bundle’s behavior in a custom Twig function:
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Http;
Blade::directive('getUrlContents', function ($url) {
return "<?php echo \\Illuminate\Support\Facades\Http::get({$url})->body(); ?>";
});
// app/Extensions/CustomTwigExtension.php
class CustomTwigExtension extends \Twig\Extension\AbstractExtension
{
public function getFunctions()
{
return [
new \Twig\TwigFunction('get_url_contents', [$this, 'fetchUrl']),
];
}
public function fetchUrl(string $url): string
{
return Http::get($url)->body() ?? '';
}
}
RemoteContentFetcher facade) to centralize HTTP logic.tightenco/ziggy or laravelcollective/html) supports custom functions, but the bundle’s eZ Publish legacy operator would need a custom parser or manual replacement.curl, while Laravel uses Guzzle. Ensure no global curl configurations interfere (e.g., php.ini settings).Http client provides exceptions and retries; the bundle’s silent failures would need explicit translation.Http client.composer.json.curl usage (e.g., SSL, timeouts).curl calls block PHP workers, risking:
Illuminate\Support\Facades\Cache) for static external content.| Scenario | Bundle Behavior | Laravel Alternative Behavior |
|---|---|---|
| HTTP 404/500 | Returns empty string | Throws HttpException or returns null |
| Network Timeout | Returns empty string | Throws ConnectException |
| SSL Certificate Error | Depends on curl config |
Configurable via Guzzle middleware |
| Rate Limiting | No retries | Retry logic via Guzzle middleware |
| Malformed URL | Returns empty string | Throws InvalidArgumentException |
curl options).How can I help you explore Laravel packages today?