Since `doctrine/cache` is deprecated, this package should be deprecated
Since upstream doctrine/cache is now deprecated and there are other options for caching in a PSR-16 compatible way (symfony/cache, laminas/cache, cache/cache, more), apart from existing doctrine/cache:^1.11 users, I don't see any point in continuing maintenance of this package.
I had a message from someone asking how to upgrade their code that uses doctrine/cache (specifically a Filesystem cache) when using Browscap in a Laravel project for example. This is my reply, but made public since I'd prefer the information to be open to all:
As doctrine/cache is deprecated you need to use another PSR-16 compatible cache. Essentially, the issue is that doctrine/cache became end of life.
The Roave/DoctrineSimpleCache package only existed to provide a PSR-16 compatible adapter for doctrine/cache, but as the latter is deprecated, it made sense to deprecate the Roave adapter.
Since you're likely using Laravel Cache, it would make sense to use that to store the cached data Browscap needs, but I don't know if Laravel Cache is PSR-16 compatible. If it is, just pass the cache in as the parameter to Browscap. If not, you'd need some kind of adapter, I imagine one already exists maybe.
Oh, if anyone is looking for a very simple almost drop-in replacement for doctrine/cache (not exactly, but it's pretty straightforward), please definitely check out https://www.php-cache.com/
I had a message from someone asking how to upgrade their code that uses doctrine/cache (specifically a Filesystem cache) when using Browscap in a Laravel project for example. This is my reply, but made public since I'd prefer the information to be open to all:
As doctrine/cache is deprecated you need to use another PSR-16 compatible cache. Essentially, the issue is that doctrine/cache became end of life. The Roave/DoctrineSimpleCache package only existed to provide a PSR-16 compatible adapter for doctrine/cache, but as the latter is deprecated, it made sense to deprecate the Roave adapter. Since you're likely using Laravel Cache, it would make sense to use that to store the cached data Browscap needs, but I don't know if Laravel Cache is PSR-16 compatible. If it is, just pass the cache in as the parameter to Browscap. If not, you'd need some kind of adapter, I imagine one already exists maybe.
I figured it out.. I started tinkering last night and so far it looks to be working :)
Yes, Laravel Cache is PSR-16 compatible out of the box.
I am using Laravel 8 and Redis as the cache.
I have a job that runs periodically (nightly or monthly?) that populates the cache:
use Illuminate\Support\Facades\Log; use Symfony\Component\Cache\Psr16Cache;
$adapter = app('cache.psr6'); $browsercapUpdater = new BrowscapUpdater(new Psr16Cache($adapter), Log::getLogger()); $browsercapUpdater->update(IniLoaderInterface::PHP_INI_FULL);
Then, to get the browser capabilities:
use Illuminate\Support\Facades\Log; use Symfony\Component\Cache\Psr16Cache;
$adapter = app('cache.psr6'); $browscap = new Browscap(new Psr16Cache($adapter), Log::getLogger()); $browser = $browscap->getBrowser();
I am still testing, but so far it seems to be working great.
-Rob
Great to hear @streamingsystems :smile: :+1: