Yii Framework Forum: Agile Yii Book Chapter 9 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Agile Yii Book Chapter 9 authManager configuration problem

#1 User is offline   phcamera 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-August 10
  • Location:Hungary Budapest

Posted 28 August 2010 - 05:19 AM

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:

Quote

root@none-laptop:~/server# trackstar/protected/yiic shell
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
Yii Interactive Tool v1.1 (based on Yii v1.1.2)
Please type 'help' for help. Type 'exit' to quit.
>> help
At the prompt, you may enter a PHP statement or one of the following commands:
- controller
- crud
- form
- help
- model
- module
- rbac

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.

>> rbac

Error: an authorization manager, named 'authManager' must be configured to use this command.
If you already added 'authManager' component in application configuration,
please quit and re-enter the yiic shell
.
>>
[9]+ Megállítva trackstar/protected/yiic shell
root@none-laptop:~/server#
root@none-laptop:~/server/trackstar#

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:
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


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
0

#2 User is offline   ekerazha 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 526
  • Joined: 10-October 08
  • Location:European Union

Posted 28 August 2010 - 10:41 AM

It's strange... however, restore the original framework code and try to copy here your config file...
Yii user #37
0

#3 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 29 August 2010 - 11:17 PM

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

#4 User is offline   phcamera 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-August 10
  • Location:Hungary Budapest

Posted 30 August 2010 - 04:02 PM

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!
0

#5 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 30 August 2010 - 09:45 PM

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.c...9.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.
0

#6 User is offline   phcamera 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-August 10
  • Location:Hungary Budapest

Posted 02 September 2010 - 01:43 PM

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. ::)
0

#7 User is offline   phcamera 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-August 10
  • Location:Hungary Budapest

Posted 02 September 2010 - 04:52 PM

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.
Would you be so kind to help me?
Thanks.

0

#8 User is offline   macinville 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 268
  • Joined: 25-October 10
  • Location:Marikina City, Philippines

Posted 26 October 2010 - 12:03 AM

View Postphcamera, on 02 September 2010 - 04:52 PM, said:

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.
Would you be so kind to help me?
Thanks.



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.

This post has been edited by macinville: 26 October 2010 - 12:05 AM

Tell your tail.
Don't be shy to upvote a post if it was able to help you
0

#9 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 363
  • Joined: 23-July 09

Posted 26 October 2010 - 12:12 AM

View Postmacinville, on 26 October 2010 - 12:03 AM, said:

Maybe it has something to do with the version I am using, which is 1.1.4?


I'm using 1.1.5 dev and it works just fine ???
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#10 User is offline   alkazal 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 05-May 11
  • Location:Malaysia

Posted 05 May 2011 - 02:48 PM

View Postmacinville, on 26 October 2010 - 12:03 AM, said:

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.



Hi there!

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

thanks!
0

#11 User is offline   Dennis.Lan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 12-September 10

Posted 12 January 2012 - 09:09 PM

:( 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.


0

#12 User is offline   Jampire 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 10-January 11
  • Location:Gomel, Belarus

Posted 16 January 2012 - 08:52 AM

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.


Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users