php-soap / cached-engine
A cache decorator for php-soap/engine
Fund package maintenance!
Open Collective
Installs: 1 404
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ~8.2.0 || ~8.3.0 || ~8.4.0
- php-soap/engine: ^2.13.0
- psr/cache: ^3.0
- psr/cache-implementation: ^3.0
Requires (Dev)
- phpunit/phpunit: ^10.0
- symfony/cache: ^7.0 || ^6.4
- vimeo/psalm: ^5.26
README
This package contains a cache wrapper for a SOAP engine. For more information about the engine, please check the php-soap/engine package.
Want to help out? 💚
Want more information about the future of this project? Check out this list of the next big projects we'll be working on.
Prerequisites
You can choose what cache implementation you want to use. This package expects some PSR implementations to be present in order to be installed:
- PSR-6:
psr/cache-implementation
likesymfony/cache
orcache/*
Example:
$ composer require symfony/cache
Installation
composer install php-soap/cached-engine
Engines
This package provides engines that can be used in a generic way:
CachedEngine
You can cache a complete engine so that you don't have to reload a WSDL on every HTTP request.
use PhpSoap\CachedEngine\CachedEngine; use Soap\CachedEngine\CacheConfig; use Soap\Engine\Engine; $engine = new CachedEngine( $yourPsr6CachePool, new CacheConfig( key: 'cached-engine', ttlInSeconds: 3600 ), static function (): Engine { return new YourSoapEngine(); } );
Note: This driver doesn't work well with the LazyEngine
because of its closures that cannot be serialized.
Since this engine is already lazy, you can use it as a direct replacement.
Drivers
This package provides drivers that can be used in a generic way:
CachedDriver
You can cache a complete driver so that you don't have to reload a WSDL on every HTTP request.
use PhpSoap\CachedEngine\CachedDriver; use Soap\CachedEngine\CacheConfig; use Soap\Driver\Driver; $driver = new CachedDriver( $yourPsr6CachePool, new CacheConfig( key: 'cached-engine', ttlInSeconds: 3600 ), static function (): Driver { return new YourSoapDriver(); } );
Concrete example:
use Soap\CachedEngine\CacheConfig; use Soap\CachedEngine\CachedDriver; use Soap\Encoding\Driver; use Soap\Wsdl\Loader\StreamWrapperLoader; use Soap\WsdlReader\Wsdl1Reader; use Symfony\Component\Cache\Adapter\RedisAdapter; $driver = new CachedDriver( new RedisAdapter( RedisAdapter::createConnection('redis://localhost') ), new CacheConfig('your-soap-driver', ttlInSeconds: 3600), static fn() => Driver::createFromWsdl1( (new Wsdl1Reader( new StreamWrapperLoader() ))($wsdlLocation) ) );