Download the PHP package ginsen/img-finder without Composer
On this page you can find all versions of the php package ginsen/img-finder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ginsen/img-finder
More information about ginsen/img-finder
Files in ginsen/img-finder
Package img-finder
Short Description App to find images in several public repositories
License MIT
Informations about the package img-finder
img-finder
PHP Library to find images in several public repositories
Install
Config file
With YAML format
Create a configuration file in yaml format, img-finder.yml
, with the following content:
With PHP format
Create config file with PHP is very similar at YAML, create php file format, as below.
And replace your credentials for use your contract services and delete the repositories that do not have credentials for their use.
If you do not have credentials to use GoogleTranslate remove this translator service, the dictionary does not need credentials, you can configure it to translate the search terms you want to English, such as a tag cloud. Note that the dictionary is not useful for free text searches.
Use
With YAML format
Create a config instance with the created yml file, and inject it into the main ImgFinder class.
With PHP format
With the PHP config file it is done as follows.
Ready
ImgFinder is now available to query image repositories, just it only necessary to create a request.
Request in Pexels & Unsplash repositories
Both requests are the same, "nature" is the search term, 1 is the default page, 10 is the number of response images for each repository, "landscape" is the orientation ('landscape' or 'portrait'), width is equal to 1200px and finally 320 is the width for thumbnails.
Request to search only in one repository
Search
Finally, you only need to perform the search.
This is the whole code of the entire operation.
Show all public repositories
To show all available repositories.
Cache optional
If you wish, you can cache requests to improve performance and not stress the image repositories.
For example, if you use the symfony/cache
component you can inject it into the initial configuration.
Example:
Create Redis cache service.
All versions of img-finder with dependencies
ext-json Version *
cocur/slugify Version ^4.0
nyholm/psr7 Version ^1.5
psr/cache Version ^1.0
psr/http-client Version ^1.0
symfony/http-client Version 5.4.*
symfony/translation Version 5.4.*
symfony/yaml Version 5.4.*