silverstripe / silverstripe-search-client-php
A PHP client to support HTTP requests to the Silverstripe Search API
dev-main
2025-05-14 22:24 UTC
Requires
- php: ^8.1
- jane-php/open-api-runtime: ^7.9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- jane-php/json-schema: dev-bugfix/array-objects as 7.9.0
- jane-php/open-api-3: dev-bugfix/array-body-content as 7.9.0
This package is auto-updated.
Last update: 2025-06-23 21:19:46 UTC
README
Warning
This Client is currently an alpha, and should be treated as experimental. We're still making improvements to our specification export, and this directly impacts the Models that are generated.
Standards
This Client adheres to the follow PSR standards:
PSR | Name | Purpose |
---|---|---|
PSR-4 | Auto-loading | Class auto-loading structure |
PSR-7 | HTTP Message Interfaces | Request/Response representation |
PSR-17 | HTTP Factory Interfaces | Create requests, streams, etc |
PSR-18 | HTTP Client Interface | Send requests |
Basic usage
$plugins = [ new AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri('https://9595b293cf40d7532796c4ca67a27b81-bifrost.silverstripe.io')), new AddPathPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri('/api/v1')), new HeaderAppendPlugin([ 'Authorization' => 'Bearer ABC.123.456', ]), ]; // When no HTTP Client is provided, PSR-18 discovery will be used, and your plugins will be attached to the HTTP Client return Client::create(httpClient: null, additionalPlugins: $plugins);
Or you might like to use a different HTTP Client, for example, Guzzle:
$httpClient = new GuzzleHttp\Client(); $plugins = [ new AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri('https://9595b293cf40d7532796c4ca67a27b81-bifrost.silverstripe.io')), new AddPathPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri('/api/v1')), new HeaderAppendPlugin([ 'Authorization' => 'Bearer ABC.123.456', ]), ]; // Apply the plugins to the HTTP Client $httpClient = new PluginClient($httpClient, $plugins); // When an explicit HTTP Client is provided, it will be used return Client::create($httpClient);