Php Symfony 4.0中FilesystemCache(SimpleCache)的依赖项注入
我试图在我的一个服务类中实现一个SimpleCache具体实例,以允许缓存,但是在连接依赖项时遇到了一些问题 config/services.yml src/Services/Shouter/Sources/Twitter.phpPhp Symfony 4.0中FilesystemCache(SimpleCache)的依赖项注入,php,symfony,symfony4,Php,Symfony,Symfony4,我试图在我的一个服务类中实现一个SimpleCache具体实例,以允许缓存,但是在连接依赖项时遇到了一些问题 config/services.yml src/Services/Shouter/Sources/Twitter.php 通过在services.yaml中添加Symfony\Component\Cache\Simple\FilesystemCache:进行修复 services: Psr\SimpleCache\CacheInterface: '@Symfony\Comp
通过在services.yaml中添加Symfony\Component\Cache\Simple\FilesystemCache:
进行修复
services:
Psr\SimpleCache\CacheInterface: '@Symfony\Component\Cache\Simple\FilesystemCache'
<?php
namespace App\Services\Shouter\Sources;
use Psr\SimpleCache\CacheInterface;
class Twitter
{
/**
* Cache instance
* @var Psr\SimpleCache\CacheInterface
*/
protected $cache;
public function __construct(CacheInterface $cache)
{
$this->cache = $cache;
}
}