我试图让Smarty 3作为Symfony 2的模板引擎工作。我试图安装这个包以使smarty 3工作:
https://github.com/noiselabs/SmartyBundle
它安装得很好,但是当我按照安装说明中的话将它添加到AppKernal时,我会得到以下错误:
致命错误:在第20行的>/home/kevin/workspace/Symfony/app/AppKernel.php中找不到‘NoiseLabs\Bundle\S烈士包’类
第20行位于registerBundles()中:NoiseLabs\Bundle\S烈性Bundle(),
第二个可能与此相关的问题是,在app/config/config.yml中,如果我在模板引擎数组中添加“智能”:
templating: { engines: ['twig'] }它抛出此错误:
ServiceNotFoundException:服务“模板”依赖于不存在的>服务"templating.engine.smarty“。
我意识到小树枝和symfony一起来的,但是对于这个项目,我需要使用智能。我是遗漏了什么,还是有其他的解决办法?
下面是内核代码:
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
//new NoiseLabs\Bundle\SmartyBundle(),
new Blog\EntryBundle\BlogEntryBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
}以下是自动加载程序代码:
<?php
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
'Sensio' => __DIR__.'/../vendor/bundles',
'JMS' => __DIR__.'/../vendor/bundles',
'NoiseLabs' => __DIR__.'/../vendor/bundles',
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
'Monolog' => __DIR__.'/../vendor/monolog/src',
'Assetic' => __DIR__.'/../vendor/assetic/src',
'Metadata' => __DIR__.'/../vendor/metadata/src',
));
$loader->registerPrefixes(array(
'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',
'Twig_' => __DIR__.'/../vendor/twig/lib',
));
// intl
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
$loader->registerPrefixFallbacks(array(__DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs'));
}
$loader->registerNamespaceFallbacks(array(
__DIR__.'/../src',
));
$loader->register();
AnnotationRegistry::registerLoader(function($class) use ($loader) {
$loader->loadClass($class);
// Swiftmailer needs a special autoloader to allow
// the lazy loading of the init file (which is expensive)
require_once __DIR__.'/../vendor/swiftmailer/lib/classes/Swift.php';
Swift::registerAutoload(__DIR__.'/../vendor/swiftmailer/lib/swift_init.php');发布于 2012-02-04 19:44:57
感谢您使用SmartyBundle (我是创建者)。
该死,文件是错的。请更换线路:
new \NoiseLabs\Bundle\SmartyBundle(),通过
new \NoiseLabs\Bundle\SmartyBundle\SmartyBundle(),发布于 2012-05-20 07:18:02
我在手册上有问题,但我解决了。使用以下步骤:
https://stackoverflow.com/questions/9134946
复制相似问题