jjzjj

php - Symfony2 : "Fatal error: Class service..." while trying to include a class as an service in config. yml (TCPPDF)

coder 2024-04-08 原文

我正在尝试在 Symfony2 (2.1.4-DEV) 中使用服务容器包含类 TCPDF 的扩展。为此,我编辑了 symfony/app/config/config.yml :

services:
  extend_pdf:
    class: Acme\VSBundle\extend_pdf

在文件 symfony/src/Acme/VSBundle/extend_pdf.php 中,我有一个像这样的虚拟类:

<?php
namespace Acme\VSBundle;

// extend TCPF with custom functions
class extend_pdf extends TCPDF {

}

?>

我将其加载到 Controller 中,例如:

function testAction() {
    $extendpdf = $this->get('extend_pdf');
    return new Response('success');
}

这给了我以下错误:

Fatal error: Class 'Acme\VSBundle\extend_pdf' not found in /home/user/public_html/Acme/Symfony/app/cache/dev/appDevDebugProjectContainer.php on line 417 Call Stack:...

缓存是空的,我不知道为什么找不到我的类。

谢谢

最佳答案

您的命名空间名称不正确:ModurexCRM\VSBundle,请更正命名空间名称。

关于php - Symfony2 : "Fatal error: Class service..." while trying to include a class as an service in config. yml (TCPPDF),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13457381/

有关php - Symfony2 : "Fatal error: Class service..." while trying to include a class as an service in config. yml (TCPPDF)的更多相关文章

随机推荐