emersonthis emersonthis - 8 days ago 6
PHP Question

CakePHP plugin throws "Missing View" error but view file exits

I'm writing a basic plugin for my cakePHP 2.x app following the instructions in the book.

I've created the directory/file structure with a MyPluginAppController.php and MyPluginAppModel.php.

I added

CakePlugin::load('MyPlugin');
to the parent app's bootstrap.php file.

Then I created one Controller and Model. But for some reason when I try to view
mysite.dev/(admin)/my_plugin/my_model/
I get a "Missing View" error. It says to confirm that the view file exists, which it does!

I don't think I skipped any steps from the book. What am I doing wrong?

Update:

Controller path:
app/Plugin/MyPlugin/Controller/MyModelController.php


View path:
app/Plugin/MyPlugin/View/MyModel/admin_index.php


URL:
http://mysite.dev/admin/my_plugin/my_model/

Answer

Rename this file

app/Plugin/MyPlugin/View/MyModel/admin_index.php

To this extension .ctp

app/Plugin/MyPlugin/View/MyModel/admin_index.ctp

This is a common mistake.