please help chapter 8


(M73mit) #1

I’m working with the book Agile Web Development with Yii. In Chapter 8, it creates a php script to set up a RBAC (role based access control) so that when we access the shell at




/framework/yiic shell

it should allow us to enter a command


rbac

Pursuant to the PHP script that we created, the command creates three roles, Owner, Member and Reader with various permissions.

My problem is that, working with MAMP, when I do the command


/framework/yiic shell

or


/Applications/MAMP/framework/yiic shell

it says


-bash: yiic: command not found

Therefore, I can’t create these roles, and then I can’t continue along with the book, because I don’t know any work around. I had a similar problem in the earlier chapters, but was able to use Gii to generate the classes and models. But i don’t know how to use Gii to create the roles in case I can’t do it with the shell.

Can anyone help?

UPDATE

I did


chmod +x yiic

and now when I do


/framework/yiic shell

it seems to enter the shell, but when I type “help” it doesn’t give me the commands controller crud module rbac etc. Rather it gives me all these general commands

The shell it gives me


Error: index.php does not exist or is not an entry script file.


USAGE

  yiic shell [entry-script | config-file]


DESCRIPTION

  This command allows you to interact with a Web application

  on the command line. It also provides tools to automatically

  generate new controllers, views and data models.


  It is recommended that you execute this command under

  the directory that contains the entry script file of

  the Web application.


PARAMETERS

 * entry-script | config-file: optional, the path to

   the entry script file or the configuration file for

   the Web application. If not given, it is assumed to be

   the 'index.php' file under the current directory.



[b]The general commands (but not crud or rbac etc)

[/b]


A star (*) next to a name means that the command is disabled.


 JOB_SPEC [&]                       (( expression ))

 . filename [arguments]             :

 [ arg... ]                         [[ expression ]]

 alias [-p] [name[=value] ... ]     bg [job_spec ...]

 bind [-lpvsPVS] [-m keymap] [-f fi break [n]

 builtin [shell-builtin [arg ...]]  caller [EXPR]

 case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir]

 command [-pVv] command [arg ...]   compgen [-abcdefgjksuv] [-o option

 complete [-abcdefgjksuv] [-pr] [-o continue [n]

 declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N]

 disown [-h] [-ar] [jobspec ...]    echo [-neE] [arg ...]

 enable [-pnds] [-a] [-f filename]  eval [arg ...]

 exec [-cl] [-a name] file [redirec exit [n]

 export [-nf] [name[=value] ...] or false

 fc [-e ename] [-nlr] [first] [last fg [job_spec]

 for NAME [in WORDS ... ;] do COMMA for (( exp1; exp2; exp3 )); do COM

 function NAME { COMMANDS ; } or NA getopts optstring name [arg]

 hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern ...]

 history [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [ elif

 jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si

 let arg [arg ...]                  local name[=value] ...

 logout                             popd [+N | -N] [-n]

 printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]

 pwd [-LP]                          read [-ers] [-u fd] [-t timeout] [

 readonly [-af] [name[=value] ...]  return [n]

 select NAME [in WORDS ... ;] do CO set [--abefhkmnptuvxBCHP] [-o opti

 shift [n]                          shopt [-pqsu] [-o long-option] opt

 source filename [arguments]        suspend [-f]

 test [expr]                        time [-p] PIPELINE

 times                              trap [-lp] [arg signal_spec ...]

 true                               type [-afptP] name [name ...]

 typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit

 umask [-p] [-S] [mode]             unalias [-a] name [name ...]

 unset [-f] [-v] [name ...]         until COMMANDS; do COMMANDS; done

 variables - Some variable names an wait [n]





(George Buckingham) #2

Where are you calling the yiic script from? As in, are you calling from your project directory? Try calling yiic like this:


(current directory): /path/to/my/project /path/to/yii/framework/yiic shell

Hope that makes sense


(Luckymancvp) #3

I have same problem.

When my current directory is application directory , Seem it run index.php rather run shell application.


(Seekingvengeance4solace) #4

I had the same problem several days ago.

You should navigate to :


$ cd /path/to/Webroot/trackstar

You can use either:


protected/yiic shell

or:


../YiiRoot/framework/yiic shell


(Gj Guojing) #5

I got the same problem at the begining!

Here is my solution:




$cd /var/www/my_web_application_path/

$sudo YiiRoot/framework/yiic shell protected/config/main.php




(Andrei) #6

Hi,

For me it worked with :


./yiic shell

on the command line from inside your "framework" folder !

Give it a try ;)