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
Packagist Api

Packagist Api Laravel Package

spatie/packagist-api

Search Packagist and fetch package details via the official Packagist API. Provides a simple PackagistClient built on Guzzle with a URL generator, plus helpers to list all packages or filter by vendor/type, and browse popular packages with pagination.

View on GitHub
Deep Wiki
Context7

The easiest way to work with the packagist API

Frequently asked questions about Packagist Api
How do I install spatie/packagist-api in a Laravel project?
Run `composer require spatie/packagist-api` in your project root. The package is framework-agnostic but integrates seamlessly with Laravel’s HTTP client or Guzzle. For Laravel-specific helpers, consider the community wrapper `markwalet/laravel-packagist`.
Can I use this package without Laravel?
Yes. The package is standalone and works with any PHP 8.0+ project using Guzzle or PSR-11 HTTP clients. Just instantiate `PackagistClient` with your HTTP client and `PackagistUrlGenerator`.
What Laravel versions does spatie/packagist-api support?
The package has no strict Laravel version coupling but is tested with Laravel 9+ and 10+. Ensure your project’s PHP 8.0+ requirements align with the package’s dependencies. For older Laravel versions, check compatibility with Guzzle 6/7.
How do I cache Packagist API responses to avoid rate limits?
Wrap API calls in Laravel’s cache drivers (e.g., `Cache::remember()`) or use queue workers for async fetches. For high-frequency use, implement exponential backoff with Guzzle’s middleware or a library like `spatie/laravel-queueable-caching`.
Does this package support searching for specific package versions?
No, this package focuses on package metadata (names, vendors, types) and popular packages. For version-specific data, use Packagist’s `/p/{package}.json` endpoint directly or extend the client with custom methods via the adapter pattern.
How do I handle API failures or rate limits in production?
Implement retries with Guzzle’s `RetryMiddleware` or Laravel’s `Http::withOptions(['timeout' => 30, 'connect_timeout' => 5])`. For rate limits, cache responses aggressively or use a fallback (e.g., local JSON dumps) with feature flags to toggle API usage.
Is there a Laravel Facade or Service Provider for this package?
The package itself doesn’t include a Facade, but you can bind it to Laravel’s container in a Service Provider. For a ready-made solution, use the community wrapper `markwalet/laravel-packagist`, which provides Facades and Artisan commands.
Can I extend this package to add custom Packagist API endpoints?
Yes. The package uses dependency injection for the `PackagistUrlGenerator`, so you can create a custom generator to support unsupported endpoints. Override the `generateUrl()` method or use the adapter pattern to abstract the client interface.
How do I integrate this with Laravel Scout for package search?
Use the package to fetch package metadata, then index it in Scout (e.g., Algolia or Meilisearch). Create a custom searchable model with a `toSearchableArray()` method that includes Packagist data. For real-time updates, trigger Scout indexing via Laravel events.
What’s the best way to test this package in a CI/CD pipeline?
Mock the Guzzle client in unit tests using `Mockery` or PHPUnit’s `createMock()`. For integration tests, use a test HTTP client with a local Packagist API mock (e.g., `vcr/vcr` for recording responses). Test edge cases like rate limits and invalid package names.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport