Weave 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

Get Header Laravel Package

yakeing/get_header

yakeing/get_header is a lightweight Laravel/PHP package for retrieving HTTP headers from URLs. It provides a simple way to inspect response status, content type, redirects, and other header metadata in your applications.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install the package via Composer: composer require yakeing/get_header. Since the repository is archived, you may need to add it manually if Packagist no longer serves it, but the package is still available.
  • Inspect the source immediately: the package is tiny, so open vendor/yakeing/get_header/ and look for the primary class or function (likely yakeing\get_header\GetHeader or a global get_header() function). The README on GitHub shows a basic example, but it may be outdated.
  • First use case: run a quick smoke test in php artisan tinker:
    $headers = get_header('https://example.com');
    // or
    $headers = (new \yakeing\get_header\GetHeader())->get('https://example.com');
    
    Inspect the returned array to confirm it matches PHP’s native get_headers() structure (numeric and associative keys). Use this to verify status codes, Content-Type, redirect chains, etc.
  • Integrate into a simple Artisan command first (e.g., php artisan headers:check https://example.com) to validate real-world behavior before wiring it into controllers or jobs.

Implementation Patterns

  • Wrap the package in a Laravel service. Create App\Services\HeaderFetcher with a fetch(string $url): array method that delegates to the package. Bind it in a service provider and inject it where needed. This isolates the archived dependency and lets you swap it for Guzzle later without changing call sites.
  • Use it for endpoint health checks. Schedule an Artisan command (e.g., daily) to fetch headers from critical external URLs (webhooks, APIs) and assert expected status codes and Content-Type. Log mismatches to Laravel’s log or a monitoring channel.
  • Validate user-submitted URLs. In a form request or custom validation rule, fetch headers to confirm a URL returns 200 and the correct Content-Type (e.g., image/* for avatar URLs). Guard against SSRF by restricting schemes/hosts and avoiding internal IPs.
  • Create a facade for convenience. Define Header facade pointing to your wrapper service, so you can write Header::get($url) in controllers. This mimics Laravel’s Http facade but returns the raw header array.
  • Combine with queues for bulk operations. If checking many URLs, dispatch a job per URL, fetch headers, and store results in cache or database. This prevents blocking web requests.
  • Fallback to Laravel’s HTTP client. For most HTTP interactions, prefer Illuminate\Support\Facades\Http (Guzzle). Use this package only when you specifically need the exact get_headers()-style output (e.g., multiple Set-Cookie headers flattened into an array) or want a zero-dependency alternative.

Gotchas and Tips

  • Archived and unmaintained. Last release was 2019-08-06, and the package has no dependents. Audit the source for PHP 8+ compatibility and security. Treat it as a legacy utility; if you need long-term reliability, fork it or replace it with Guzzle.
  • Relies on PHP stream wrappers. The implementation likely uses allow_url_fopen and the HTTP stream wrapper. Ensure this is enabled in production (php -i | grep allow_url_fopen). If disabled, use a cURL-based wrapper instead.
  • Timeouts and redirects are not configurable via Laravel config. The package probably uses PHP defaults (30s timeout, 20 redirects). To customize, you may need to fork the code or wrap it with stream_context_create if the API supports a context parameter. Otherwise, implement your own fetcher.
  • HTTPS/SSL verification. Test against HTTPS endpoints early. The package may disable SSL verification or fail with self-signed certificates. Check the source for verify_peer settings and patch if necessary.
  • Debugging failures. If the function returns false, check network connectivity, DNS resolution, and PHP error logs. Use Log::debug('headers', $headers) or dd() in Tinker. For intermittent issues, add retry logic in your wrapper.
  • No configuration or extension points. The package is a thin function with no service provider, config file, or events. Extend it by creating your own class that calls it and adds caching (Cache::remember), retries, user-agent headers, or header parsing. Since it’s MPL-2.0, you can copy and modify the source into your app if needed (keep license notices).
  • Prefer native get_headers() for simple cases. Before adding the dependency, test PHP’s built-in get_headers($url, true). It may suffice and avoids an unmaintained package. Use yakeing/get_header only if it offers a specific improvement (e.g., better redirect handling or associative formatting) that you’ve verified.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource