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訪問基本控制器嗎?或者它只是一個基類,並且你希望只使用它? –
我想知道我是否可以同時做這兩件事? –