Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony 4.0中FilesystemCache(SimpleCache)的依赖项注入_Php_Symfony_Symfony4 - Fatal编程技术网

Php Symfony 4.0中FilesystemCache(SimpleCache)的依赖项注入

Php 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

我试图在我的一个服务类中实现一个SimpleCache具体实例,以允许缓存,但是在连接依赖项时遇到了一些问题

config/services.yml

src/Services/Shouter/Sources/Twitter.php


通过在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;
    }
}