gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:50:34 25 4
gpt4 key购买 nike

我正在尝试在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com