class SomeController extends Controller
{
public function actionIndex() {
echo 'This is some controller';
}
}
class AnotherController extends SomeController
{
public function actionIndex() {
echo 'This is another controller';
}
}
index.php?r=some
但是......
index.php?r=another
说:
PHP警告
包括(SomeController.php):未能打开流:没有这样的文件或目录
文件两者都是
test\protected\controllers\
顺便说一句,在过去我用GII控制器发生器,还试图“SomeController”作为基类...
它说:
The controller has been generated successfully. You may try it now.
Generating code using template
"C:\xampp\htdocs\yii\framework\gii\generators\controller\templates\default"...
generated controllers\YetAnotherController.php
generated views\yetAnother\index.php
done!
当我点击“立即试用”它也说:
PHP警告
包括(SomeController.php):未能打开流:没有这样的文件或目录
是的,它在\受保护\ controllers \ SomeController.php BTW就像我说的“http://localhost/yii/testapp/index.php?r =一些”工程...但gii的“YetAnotherController.php”(索引.php?r = yetAnother)和我的“AnotherController.php”(index.php?r = another)给出了它们的基类(SomeController.php)的错误。 SomeController.php的自动加载似乎存在一个问题,当它是基类时,如果我使用index.php?r = some,它可以正常工作。当我在控制器中引用Post.php时,我也遇到同样的错误...它在models/Post.php中... –
哦,那么你会从url访问基本控制器吗?或者它只是一个基类,并且你希望只使用它? –
我想知道我是否可以同时做这两件事? –