【发布时间】:2014-05-07 01:14:02
【问题描述】:
这是我的应用结构:
/application
/config
/library
/Foo
/Controler.php
/module
/User
/config
/src
/Bar
/Controler
/BarController.php
/public
/vendor
/init_autoloader.php
Controler.php 文件...
namespace Foo_Controller;
use Zend\Mvc\Controller\AbstractRestfulController;
class Foo_Controller extends AbstractRestfulController {
protected $foo;
public function getFoo()
{
return "foooo";
}
function __construct()
{
parent::__construct();
$foo = $this->getFoo();
}
}
BarController.php...
namespace Bar\Controler;
use Zend\Mvc\Controller\AbstractRestfulController;
use Foo_Controller\Foo_Controller;
use Zend\View\Model\JsonModel;
class BarController extends Foo_Controller {
.
..
....
}
在init_autoloader.php中添加路径/library文件夹
$loader = include 'vendor/autoload.php';
$zf2Path = 'vendor/zendframework/zendframework/library';
$loader->add('Zend', $zf2Path);
$loader->add('Julia', 'library'); // added the library folder
if (!class_exists('Zend\Loader\AutoloaderFactory')) {
throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
}
我收到错误 500,内容如下:
PHP 致命错误:第 # 行的 /application/module/Bar/src/Bar/Controller/BarController.php 中找不到类 'Foo_Controller\Foo_Controller'
我现在真的不知道该怎么办。我一直在互联网上搜索在 Zend Frazmework 2 中扩展控制器类的正确方法,但我似乎无法掌握它!
我在应用程序中做错了什么? 谢谢
【问题讨论】:
标签: php zend-framework2 controllers