Yii2 Gii CRUD from a MySQL Tablename that has two_words

Hi, I used Gii to create a model, controller and CRUD views from a MySQL table user_type.

The view folder Gii created is named views\user-type.

Everything appears to work ok for example: yii2basictest/web/index.php?r=user-type/index

However, if someone inadvertently uses the url with the dash ‘-’ missing from user-type e.g : yii2basictest/web/index.php?r=usertype/index

then I get the error: Invalid Parameter – yii\base\InvalidParamException

The view file does not exist: /Applications/XAMPP/xamppfiles/htdocs/yii2basictest/views/usertype/index.php

I was expecting the page to fail gracefully with a Not Found 404

Is this the expected behavior, to throw an error?

What is the best way to deal with these urls that don’t exists:

change folders names?

catch the errors?

set an apache rule?

don’t use two-word table names?

Tested using Yii2 basic template on Mac OS Apache/2.4.9 (Unix) PHP/5.5.11

Thanks for any help.

Looks like you are in a development environment with debug on, check your config file for "debug"

In a non debug environment you would get a pretty 404 message.

If you are worried about particular misspellings, add a route for them to send the user to the correct end point

Thanks Flarpy

Yes removing debug from the config does prevent debug output.

However, the missing dash scenario just results in ‘An internal server error occurred.’ message but not a 404.

Other misspellings do result in a 404 though.

index.php?r=user-type/index // Page loads ok (correct url)

index.php?r=usr-type/index // Not found 404 (misspelling)

index.php?r=userType/index // Not found 404 (camelCase)

index.php?r=usertype/index // [color="#FF0000"]Server Error (dash ‘-’ removed)[/color]

Just thought that removing the dash would also be treated as a misspelling with a Not Found 404.