我正在使用Symfony 2.7和自定义捆绑包:
我没有"使用Mycompany \ Bundle \ Mycustombundle \ Entity \ [...]"在我的控制器顶部,但如果我测试:
<?php
namespace Mycompany\Bundle\Mycustombundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class MainController extends Controller
{
public function listAction()
{
[... misc. operations ...]
[... misc. operations ...]
[... misc. operations ...]
$this->getDoctrine()->getManager()->getRepository('Mycustombundle:Download');
[... misc. operations ...]
$new_download = new Download();
// WORKS
$this->getDoctrine()->getManager()->getRepository('Mycustombundle:Info');
[... misc. operations ...]
$new_info = new Info();
// WORKS
$new_user = new User();
// FATAL ERROR 500
// In logs : Attempted to load class "User" from namespace "Mycompany\Bundle\Mycustombundle\Controller". Did you forget a "use" statement for another namespace?
[... misc. operations ...]
[... misc. operations ...]
[... misc. operations ...]
}
}
?>
怎么可能?是因为我使用下载和信息的存储库吗?