Newbie - issues on first Model/View

Hi, newbie to Yii, 15 year Middleware techie so know how to configure webserver etc.

installed Yii 2 on Sabayon Linux using XAMPP as base( existing install used for other dev work). I had a mySQL DB already created for a site I am working on, Basic couple of forms that use php to record status for a start of day check into a single DB table. I want to switch to Yii to provide login/persistence for users in this and some other functionality I have already built.

I have Yii installed and working to the point I can access the default page and gii fine. I’ve created a model based on my table ( status_records ) called StatusRecords and then created a CRUD from that. Dir listings below

entwisi-pc mim # cd models

entwisi-pc models # ls -lrt

total 20

-rwxrwxrwx 1 root root 2154 Aug 5 23:23 User.php

-rwxrwxrwx 1 root root 1892 Aug 5 23:23 LoginForm.php

-rwxrwxrwx 1 root root 1494 Aug 5 23:23 ContactForm.php

-rw-rw-rw- 1 daemon daemon 1176 Jan 14 12:51 StatusRecords.php

-rw-rw-rw- 1 daemon daemon 1664 Jan 14 12:53 StatusRecordsSearch.php

entwisi-pc models # cd ../views

entwisi-pc views # ls -lrt

total 12

drwxrwxrwx 2 root root 4096 Aug 5 23:23 site

drwxrwxrwx 2 root root 4096 Aug 5 23:23 layouts

drwxrwxrwx 2 daemon daemon 4096 Jan 14 12:53 StatusRecords

entwisi-pc views # cd StatusRecords/

entwisi-pc StatusRecords # ls -lrt

total 24

-rw-rw-rw- 1 daemon daemon 939 Jan 14 12:53 index.php

-rw-rw-rw- 1 daemon daemon 889 Jan 14 12:53 _form.php

-rw-rw-rw- 1 daemon daemon 442 Jan 14 12:53 create.php

-rw-rw-rw- 1 daemon daemon 1023 Jan 14 12:53 view.php

-rw-rw-rw- 1 daemon daemon 576 Jan 14 12:53 update.php

-rw-rw-rw- 1 daemon daemon 818 Jan 14 12:53 _search.php

Trying to access the view index throws a 404 error with the following stack trace.

exception ‘yii\base\InvalidRouteException’ with message ‘Unable to resolve the request “StatusRecords/index”.’

in /opt/lampp/htdocs/mim/vendor/yiisoft/yii2/base/Module.php:461

Stack trace:

#0 /opt/lampp/htdocs/mim/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction(‘StatusRecords/i…’, Array)

#1 /opt/lampp/htdocs/mim/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))

#2 /opt/lampp/htdocs/mim/web/index.php(12): yii\base\Application->run()

#3 {main}

Next exception ‘yii\web\NotFoundHttpException’ with message ‘Page not found.’ in /opt/lampp/htdocs/mim/vendor/yiisoft/yii2/web/Application.php:96 Stack trace:

#0 /opt/lampp/htdocs/mim/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))

#1 /opt/lampp/htdocs/mim/web/index.php(12): yii\base\Application->run()

#2 {main}

So, what have I likely to have done wrong?

Thanks!

The two things I can think of are 1) The htaccess settings to rewrite the URLs for you (you can check whether any other pages that have a route work correctly i.e. not just index.php).

  1. You need to be careful with capitalisation on the names of objects because they don’t always do what you expect in Yii. If your controller is StatusRecordsController, your controller id will be status-records/index. Some examples are here: http://www.yiiframework.com/doc-2.0/guide-structure-controllers.html#creating-controllers