Download the PHP package starkeen/yandex-search-api without Composer
On this page you can find all versions of the php package starkeen/yandex-search-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yandex-search-api
yandex-search-api
Library for Yandex Search API
Description
This library is a convenient way to interact with the Yandex Search API (the XML interface). It allows for easy integration of Yandex search functionality into your PHP projects. The library encapsulates the complex logic of interacting with the API and provides a simple and understandable interface for executing search queries.
Requirements
- PHP 8.1 or higher
ext-simplexmlext-libxml- A PSR-18 HTTP client (
psr/http-client: ^1.0) - A PSR-17 HTTP factory implementing both
RequestFactoryInterfaceandStreamFactoryInterface(psr/http-factory: ^1.0) - A PSR-3 logger (
psr/log: ^3.0)
Installation
To install the library, add it to your project using Composer:
Usage
To use the library, you need to get an API key. You can get it on the Yandex Search API page.
Configuration
To use the library, you need to provide your Yandex Search API key and your account (folder) ID. You can obtain them by registering your application on the Yandex Cloud Console.
The recommended way is to pass the credentials to the constructor (store them in a configuration file / environment variables rather than hard-coding them):
The
setApiId()/setApiKey()setters are still available but deprecated since 2.0 — prefer constructor injection.
If credentials are not provided, search() throws a
YandexSearchAPI\ConfigurationException.
Tuning the request
SearchRequest exposes setters to control the query:
Passing a value outside the allowed enum to setLanguage(), setSort() or
setFilter() throws a YandexSearchAPI\ConfigurationException.
Working with the response
search() returns a YandexSearchAPI\SearchResponse:
Error handling
| Exception | When it is thrown |
|---|---|
YandexSearchAPI\ConfigurationException |
Missing credentials, or an invalid language / sort / filter value. |
YandexSearchAPI\SearchException |
Transport error, malformed XML, or an error reported by the API (e.g. code 15). |
Both exceptions extend \RuntimeException.
Questions and Feedback
If you have questions, issues, or suggestions for improvement, please create a new issue in the Issues section on GitHub.
License
This library is distributed under the MIT license. See the LICENSE file for details.
All versions of yandex-search-api with dependencies
ext-libxml Version *
ext-simplexml Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/log Version ^3.0