[英]Symfony 2: Class not found in Controller
I've been struggling with this for some time now. 我已经为此苦了一段时间了。 It is most likely a rookie/typo problem, but I just can't find it. 这很可能是菜鸟/错字问题,但我只是找不到。
I have this class ... 我有这堂课...
<?php
namespace PriceOrQuality\POQBundle\RegExConf;
use PriceOrQuality\POQBundle\RegExConf\RegExConf;
class RegExConfIrma extends RegExConf {
public function __construct() {
$this->start_page = 'https://irma.dk';
$this->startConnection();
$this->getAllLinks();
}
}
?>
that I'm trying to load from this controller. 我正在尝试从此控制器加载。
<?php
// src/PriceOrQuality/POQBundle/Controller/CrawlerController.php;
namespace PriceOrQuality\POQBundle\Controller;
use PriceOrQuality\POQBundle\RegExConf\RegExConfIrma;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Monolog\Logger;
use Monolog\Handler\FirePHPHandler;
Class CrawlerController extends Controller {
public function testAction($page) {
if($page == 'irma') {
$regex = new RegExConfIrma();
return $this->render('PriceOrQualityBundle:Crawling:crawling_test.html.twig', array('links' => $regex->getLinks()));
}
}
}
?>
However I get this error, and I just cannot seem to find the problem. 但是,我收到此错误,并且似乎无法找到问题。
FatalErrorException: Error: Class 'PriceOrQuality\\POQBundle\\RegExConf\\RegExConfIrma' not found in /Users/Rune/Sites/poq/src/PriceOrQuality/POQBundle/Controller/CrawlerController.php line 16 FatalErrorException:错误:在/Users/Rune/Sites/poq/src/PriceOrQuality/POQBundle/Controller/CrawlerController.php第16行中找不到类'PriceOrQuality \\ POQBundle \\ RegExConf \\ RegExConfIrma'
The RegExConfIrma resides in /Users/Rune/Sites/poq/src/PriceOrQuality/POQBundle/RegExConf/RegExConfIrma RegExConfIrma驻留在/ Users / Rune / Sites / poq / src / PriceOrQuality / POQBundle / RegExConf / RegExConfIrma中
I've tried to debug: * the namespace * clearing cache * changing the namespace 我尝试调试:*名称空间*清除缓存*更改名称空间
But nothing helps. 但是没有任何帮助。
Any help is highly appreciated. 非常感谢您的帮助。
Thanks! 谢谢!
The problem was extremely rookie. 问题是新秀。
I forgot to add .php after my file extension as I use Netbeans where the logo showed is as a php file, but without the proper extension. 我忘记在文件扩展名后添加.php,因为我使用的是Netbeans,其中显示的徽标是php文件,但没有正确的扩展名。
So for anyone else finding this post with the same problem: 因此,对于任何其他人发现同样问题的帖子:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.