- What is irazasyed/php-stock-media used for?
- It is a lightweight, framework-agnostic PHP package that gives you a single interface for searching and retrieving royalty-free stock photos and videos from multiple providers. Instead of wiring up each provider's SDK separately, you make one call and let the package handle the provider differences.
- How do I install php-stock-media with Composer?
- Install it with Composer by running composer require irazasyed/php-stock-media. Then add your provider API credentials to the package configuration as described in the README. No Laravel service provider registration is needed because the package is framework-agnostic plain PHP.
- Does php-stock-media work with Laravel?
- Yes. Because it is framework-agnostic PHP, it runs fine inside a Laravel app and can be used from a controller, job, or service class. You can bind it in the service container or wrap it in your own service if you prefer dependency injection.
- How do I configure API credentials for each stock media provider?
- Credentials are supplied per provider through the package configuration, so you can enable only the providers you actually use. Keep the keys in environment variables and out of version control. Check the repository README for the exact configuration keys each provider expects.
- Can I search photos and videos through one unified interface?
- The package exposes a unified search interface covering both photos and videos, so you do not need a separate integration per media type. The exact search parameters depend on what each provider supports, so review the README for the available options.
- Which stock media providers are supported?
- The package is built around multiple royalty-free stock media providers, and the supported list can change as provider APIs evolve. Check the repository README and source for the current list before committing to an integration.
- How do I test stock media searches without hitting live APIs?
- Since the package talks to external HTTP APIs, mock the HTTP layer in your tests instead of making real network calls. In Laravel you can use Http::fake if the underlying client supports it, or inject a fake client. This keeps tests fast, deterministic, and free of rate limits.
- Is php-stock-media safe to use in production?
- Yes, with standard precautions: store API keys in environment variables, cache search results to cut down on API calls and stay within rate limits, and handle provider errors gracefully so one outage does not break your UI. You should also verify the license terms of any media you display.
- How does php-stock-media compare to using provider SDKs directly?
- Using provider SDKs directly gives you every provider-specific feature, but it means maintaining multiple clients, auth flows, and response formats. This package trades some of that depth for one consistent interface, which is usually the better fit for media pickers, asset libraries, and content search features.
- Is php-stock-media actively maintained, and can I add my own provider?
- Check the GitHub repository for recent commits, open issues, and tagged releases to gauge maintenance activity. The code is structured to be extensible, so adding a provider generally means implementing the package's provider contract rather than forking the whole library.