Download the PHP package smnandre/packapi without Composer
On this page you can find all versions of the php package smnandre/packapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smnandre/packapi
More information about smnandre/packapi
Files in smnandre/packapi
Package packapi
Short Description PHP library for retrieving package metadata, download statistics, security advisories, and quality metrics across Composer, NPM, Swift, GitHub, jsDelivr, and OSV
License MIT
Informations about the package packapi
Get insights from Composer, NPM, Swift packages, GitHub, and more via a unified, strongly‑typed API.
Features
- Multi‑ecosystem: Composer, NPM, Swift packages, GitHub, jsDelivr, OSV, BundlePhobia
- Analyses: Metadata, downloads, security, activity, quality
- Strong typing: PHP 8.3+ with strict types
- Extensible: Provider/factory architecture
- Well‑tested: Extensive automated test suite
- Lean deps: Symfony components and PSR interfaces
- HTTP/3 (QUIC) support with graceful fallback
Quick Start
Installation
Basic Usage
The default preset configures Packagist, NPM, GitHub, jsDelivr, and OSV. PackageReport keeps every detailed result typed and adds a compact summary, completeness state, and common decision values.
Supported Package Types
| Ecosystem | Package Type | Metadata | Downloads | Security | Activity | Content | Bundle Size |
|---|---|---|---|---|---|---|---|
| Composer | ComposerPackage |
Yes | Yes | Yes | Yes | Yes | No |
| NPM | NpmPackage |
Yes | Yes | Yes | Yes | Yes | Yes |
| Swift | SwiftPackage |
Via GitHub | Via jsDelivr | Via GitHub | Via GitHub | Via GitHub/jsDelivr | No |
GitHub providers can enrich any package that has a GitHub repository URL. They expose repository metadata, content, activity, and security advisories, but not registry download counts.
Usage Examples
Package Metadata Analysis
Download Statistics
Swift Package CDN Statistics
Swift packages are identified by their GitHub owner and repository. jsDelivr tracks CDN requests for tagged GitHub releases; these counts measure CDN use, not SwiftPM resolution downloads.
Security Advisory Scanning
Project Activity Analysis
Package Content Analysis
Bundle Size Analysis (NPM)
Configuration
HTTP/3 (QUIC)
PackApi supports HTTP/3 for improved performance:
Caching
Enable HTTP caching at the Symfony HTTP client level (e.g., CachingHttpClient with an HttpKernel Store). PackApi does not require a separate configuration object.
Logging
Pass a PSR‑3 logger to HttpClientFactory to log outgoing requests in examples and providers.
GitHub Authentication
For higher GitHub rate limits, provide a token:
Without an explicit token, the default builder reads GITHUB_TOKEN from the environment.
Architecture
PackApi uses a clean, extensible architecture:
Core Components
- Packages: Represent different package types (
ComposerPackage,NpmPackage,SwiftPackage) - Inspectors: Analyze specific aspects (metadata, downloads, security, etc.)
- Providers: Fetch data from external sources (Packagist, GitHub, NPM, etc.)
- Models: Strongly-typed value objects for results
- Facade: Runs a configured set of inspectors through one entry point
Provider Pattern
Each inspector accepts one or more providers from the corresponding factory. Providers are tried in order until one succeeds.
Testing
PackApi has comprehensive test coverage:
Examples
Run the sample scripts in examples/ to try PackApi quickly:
examples/metadata-analysis.php: print package metadataexamples/download-stats-analysis.php: print download periodsexamples/content-analysis.php: analyze files and flagsexamples/activity-analysis.php: summarize repo activity (setGITHUB_TOKENfor richer data)examples/security-analysis.php: list security advisories (OSV/GitHub)examples/bundlephobia-size.php: show NPM bundle sizesexamples/all-analysis.php: run a combined analysis with sensible fallbacks
Usage:
Adding New Providers
Requirements
- PHP 8.3+ (uses modern PHP features)
- ext-json (for API responses)
- ext-curl (for HTTP requests)
- ext-mbstring (for string handling)
Optional
- ext-curl with HTTP/3 (for QUIC support)
- Redis/Memcached (for distributed caching)
Contributing
Contributions are welcome! Please start by creating an issue to discuss your changes.
Credits
Created and maintained by Simon André.
[!TIP] This library is developed and maintained by a single developer in their free time.
To ensure continued maintenance and improvements, consider sponsoring development.
License
MIT License - see LICENSE file for details.
All versions of packapi with dependencies
psr/log Version ^3.0
symfony/cache-contracts Version ^3.6
symfony/http-client-contracts Version ^3.6
symfony/yaml Version ^7.3 || ^8.0