Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Since doctrine/cache is deprecated, this package should be deprecated #41

Open
asgrim opened this issue Aug 24, 2021 · 4 comments
Open
Labels

Comments

@asgrim
Copy link
Member

asgrim commented Aug 24, 2021

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.

@asgrim
Copy link
Member Author

asgrim commented Sep 8, 2021

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.

@asgrim
Copy link
Member Author

asgrim commented Sep 8, 2021

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/

@streamingsystems
Copy link

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

@asgrim
Copy link
Member Author

asgrim commented Sep 8, 2021

Great to hear @streamingsystems 😄 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants