我有一些问题来实现twig扩展.我需要创建自己的过滤器(子过滤器).所以我想过使用twig扩展.
我在MyApp\Bundle\WebsiteBundle \上创建了一个名为"Extension"的文件夹,并且文件:WebsiteExtension.php
namespace Bundle\WebsiteBundle\Extension;
class WebsiteExtension extends \Twig_Extension {
    public function getFilters() {
        return array(
            'substr'  => new \Twig_Filter_Method($this, 'substrFilter'),
        );
    }
    public function substrFilter($sentence, $start, $end) {
        return substr($sentence, $start, $end);
    }
    public function getName()
    {
        return 'website_extension';
    }
}
然后在/ app/config上的config.yml上
services:
    Website.twig.extension:
        class: MyApp\Bundle\WebsiteBundle\Extension\WebsiteExtension
        tags:
            - { name: twig.extension }
但是错误发生了:
"Fatal error: Class 'MyApp\Bundle\WebsiteBundle\Extension\WebsiteExtension' not found in .../appDevDebugProjectContainer.php on line 1391"
这很奇怪,因为文件和类存在......我错过了什么,但是什么?