CRUD application with Gii throws errors

Hello. I’m new in yii and i’m trying to dive into it.

I’m following the tutorial by creating my first app in yii.

http://www.yiiframework.com/doc/guide/1.1/en/quickstart.first-app

I managed to reach the tutorial till the step 2. Implementing CRUD Operations. At the step Generating User Model i get the following error:

Fatal error: Class ‘Controller’ not found in C:\xampp\htdocs\yiidemo\protected\controllers\SiteController.php on line 4

I use xampp stack 1.7.3 on windows 7 64 bit. The directories are fully writable by ‘Everyone’.

Any advice?

Every application generated with using yiic webpp tool has its controllers (actually the one and only - SiteController) extending not from base CController class but from private declared one Controller class. It is declared in protected/components/Controller.php. Make yourself sure that you haven’t removed this file from that folder and if it is still there, then check your protected/config/main.php (main configuration file for application) if you have following lines in it:


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

	),

If you removed components folder from auto-load list, your Controller class from Controller.php file is not loaded and your PHP cannot find it, displaying error like you cited.

I’m using exactly the same version of XAMPP (only Lite edition) on exactly the same system and everything works fine. Beside such errors are not related in any way to server configuration.

You should strongly avoid giving write permissions to all folders and to all users! You’re asking yourself for a big trouble if you mistakenly copy folders with that access setings to your web-server. You should only make folders assets and protected/runtime writeable by webserver process and all others on read only access!

Thank you for answering.

I created the first step of the application by using the yiic tool by following the steps from the book: Agile web application development with yii 1.1 and PHP5 from PAKT. I was getting the same error so i tried to figure out where the problem was as the controller file was there! I couldn’t find any solution till i found the Gii tool at the tutorial i mentioned above. I tried to continue the application setup by following the above tutorial which lead to the same error. I didn’t removed any files or classes. I read on a forum that it could be a write permission problem hence my write permission to Everyone just to check if there lied the problem. I know the caution about giving access to folders but to be honest i didn’t cared much at that moment as 1) its a development machine and 2) it was just to see if the problem relied on the permissions.

I’m still searching to find the problem. I could try to setup yii on a linux box i have at home but to be honest i would prefer to resolve the problem at my wamp box first.