-
Notifications
You must be signed in to change notification settings - Fork 82
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
browscap-php is incompatible with psr/cache 3 (e.g. Symfony Cache) #432
Comments
its been half a year... are there any updates? do you need help upgrading this? |
If a patch can be made, sure, it would be welcome 👍 thanks. Please note: we must retain support for |
That is the problem indeed - Main reason for me bringing this up were release notes of v7.0.0 with #418 which made me think it should be compatible with Symfony 6, but it seems that was only about specific Symfony component. |
You can reproduce this issue if you
|
Additionally: Since Line 36 in c4d665a
psr/cache ^2.0 || ^3.0
Requested this here matthiasmullie/scrapbook#54 Isolate the Commands and reduce dependencies? |
I found out, that you can circumvent this issue by:
If someone has the same issue, try this. I hope it helps :). No clue why composer is throwing this issue while updating but if someone can bring more light into this, why this happens, I am definitely interested. |
Hello guys, I don't know if the following snippets can help you but here's how I managed to get Symfony's cache working with Browscap. First, register a new cache pool: # config/packages/cache.yaml
framework:
cache:
pools:
# To prevent the browscap cache being deleted by the `cache:clear`
# command. A custom cache pool is used.
#
# Note: this cache can be cleared using the
# `cache:pool:clear browscap_cache` in order to force the
# browscap cache to be reloaded.
browscap_cache:
adapter: cache.adapter.filesystem Then, configure the dependencie for Browscap classes: # config/services.yaml
services:
# As Browscap uses a PSR-16 cache but Symfony use a PSR-6 cache, we need to
# wrap the PSR-6 cache into a PSR-16 cache
Symfony\Component\Cache\Psr16Cache:
arguments:
# The cache pool is defined in `config/packages/cache.yaml`
# the name matters, it must be the same as the one defined in cache.yaml
- '@browscap_cache'
BrowscapPHP\Browscap:
arguments:
# Note that the used cache must be the same as the one use for
# `BrowscapPHP\BrowscapUpdater`
- '@Symfony\Component\Cache\Psr16Cache'
- '@logger'
BrowscapPHP\BrowscapUpdater:
arguments:
# Note that the used cache must be the same as the one use for
# `BrowscapPHP\Browscap`
- '@Symfony\Component\Cache\Psr16Cache'
- '@logger' Now, you can directly inject Browscap classes and it will work. For instance: <?php
use BrowscapPHP\Browscap;
readonly class FooBarService
{
public function __construct(
private Browscap $browscap,
) {
}
public function test(Request $request)
{
$information = $this->browscap->getBrowser($request->headers->get('User-Agent'));
}
} |
Tried to use browscap-php with Symfony 6 (symfony/skeleton) but there is dependency conflict:
Is there any way to resolve this?
The text was updated successfully, but these errors were encountered: