Agile Yii Book Chapter 9

Hi!

Please help me!

I’ve stucked on the 186th page of chapter 9.

On that page the RbacCommand.php is ready and the only thing what I should do according to the book is the running of the yiic shell and the rbac command but unfortunately I got this error:

This error suggests me to configure the authManager, but I did it as the book wrote it on the 179th page. The framework version is the same as in the book. So what should i do?

I commented out the if statement from the RbacCommand.php:


 if(($this->_authManager=Yii::app()->authManager)===null)            

      {                 

            echo "Error: an authorization manager, named 'authManager' must be configured to use this command.\n";                 

            echo "If you already added 'authManager' component in application configuration,\n";                 

            echo "please quit and re-enter the yiic shell.\n";                 

            return;             

      }



But I got this Error:

[color="#FF0000"]create, read, update and delete user

create, read, update and delete project

create, read, update and delete issue

Would you like to continue? [Yes|No] y

PHP Fatal error: Call to a member function clearAll() on a non-object in /home/abiro/server/yii-core/framework/cli/commands/shell/RbacCommand.php on line 36[/color]

So, would you be so kind to help me? It seems to me the authManager configuration what I’ve done according to the book is not enough or I’ve made a mistake somewhere.

Thanks in advance

It’s strange… however, restore the original framework code and try to copy here your config file…

Yes. Please provide the entire contents of your /protected/config/main.php file. This will help us better understand the issue.

Hi!

I’ve looked over the main.php config file but i dont think that in this file would be the problem. I have found no errors in it.

Although when I started to create the environment I copied the downloaded framework to the root folder of my localhost server. After than I created the trackstar application folder next to the framework folder. So the application is not under the framework folder. Could that be the problem or the file contains something what i haven’t noticed ?

If the problem coming from the different path than how can i solve it?




<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

        

        

    

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'My Web Application',


	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

	),

        

        'modules'=>array(

                'gii'=>array(

                'class'=>'system.gii.GiiModule',

                'password'=>'PanAvision',

                ),

        ),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),


		// uncomment the following to enable URLs in path-format

		/*

		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),

		*/

		//'db'=>array(

		//	'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

		//),

		// uncomment the following to use a MySQL database

		

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=trackstar_dev',

			'emulatePrepare' => true,

			'username' => 'myname',

			'password' => 'mypass',

			'charset' => 'utf8',

		),

                

                'authManager'=>array(

                'class'=>'CDbAuthManager',

                'connectionID'=>'db',

                ),

		

		'errorHandler'=>array(

			// use 'site/error' action to display errors

            'errorAction'=>'site/error',

        ),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				// uncomment the following to show log messages on web pages

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'webmaster@example.com',

	),

        




);



thx for help!

Well, nothing jumped out as an issue with your config file. I have re-tested this myself on my local environment for chapter 9, and I am unable to produce the error you are getting.

I have uploaded the entire application codebase (Yii framework 1.1.2 NOT included) for this trackstar application through chapter 9 here:

http://www.yippyii.com/chapter9.trackstar.tgz

If you want to download it, maybe you can compare what is here to what you have to see if you notice any glaring differences.

Hi!

Sorry for the lately answer, but I was too busy in the last few days. I will try to compare the code with my mine. Although I did it once with the code what was linked to the book. It seems to me this code you have linked here is the same what was linked to the book.

Anyway I will continue the searching. Thx for help. ::)

Hi!

I’ve looked over the code again. Actually I haven’t found any difference. Although at the first time when I couldn’t run the rbac command in the yiic shell – cause it couldn’t be able to load my rbac command class, I moved it under the cli/shell etc… folder of the framework. After this it was able to load my rbac class but it couldn’t be able to find ‘authManager’ component.

…cause it wasn’t there.

So that was the reason of that error message cause I moved RbacCommand.php under that framework folder what I mentioned above.

But unfortunately I don’t know where should I change the path of the framework configs in order to be able to see the my application: protected/commands/shell/ path where the RbacCommand.php is.

[b]Would you be so kind to help me?

Thanks.[/b]

Same experience here. Putting the RbacCommand.php under the /protected/commands/shell/ did not make the rbac available in the list when typed ‘help’ in yiic shell until I put it under the cli folder. Maybe it has something to do with the version I am using, which is 1.1.4?

I am using srbac extension now, but it would be nice if I can run the RbacCommand.php. Is there a file to be changed in base folder so that it will look for the commands under protected/commands/shell directory?

Edit:

Sorry for bumping into an old thread. Next time I will look for the dates first before replying.

I’m using 1.1.5 dev and it works just fine ???

Hi there!

Have you found the solution for it? I got the same situation here. I am using version 1.1.6.

thanks!

:( I have the same problem. I use v.1.1.9




D:\www\yii\framework>yiic shell D:\www\trackstar\protected\commands\shell\RbacCommand.php

Yii Interactive Tool v1.1 (based on Yii v1.1.9)

Please type 'help' for help. Type 'exit' to quit.

>> help rbac

At the prompt, you may enter a PHP statement or one of the following commands:

 - controller

 - crud

 - form

 - help

 - model

 - module


Type 'help <command-name>' for details about a command.


To expand the above command list, place your command class files

under 'protected/commands/shell', or a directory specified

by the 'YIIC_SHELL_COMMAND_PATH' environment variable. The command class

must extend from CConsoleCommand.




Hi

You must be in the YiiRoot folder! Not In Framework folder to run shell command! Also you have to run yiic file that is situated in YiiFoor folder, not in Framework folder!

If It’s still not work, you can point the right config file to yiic shell command.