Can't execute yiic with shell command

Using MAMP (on a Mac), with Yii installed in /Application/MAMP/htdocs I was able to create a web app by changing into /htdocs/framework and then running


php yiic webapp ../demo

This created a demo app in the htdocs folder.

Now I am trying to access the shell to do CRUD. I moved into /htdocs/demo


/Application/MAMP/htdocs/framework/yiic shell

but I got command not found.

I tried


./protected/yiic shell

and it printed out a long page with the title


<title>PHP Error</title>

Does anyone know how I can access the shell to do crud?

I know that I can use Gii to do CRUD, but i’m following a tutorial that does some other stuff with the shell so I need to learn how to use it.

first of all, you need to tell us what error you get.

reading raw html in console might be hard, so you could redirect output to a file and open it in the browser.


./protected/yiic shell > output.html

Navigate to the protected folder and run:


./yiic

You should be given a list of available commands.

Make sure that the executable bit is set.

You need the dot-slash before the command.

This is an error message I’m getting

It can be a problem of database connection.

Are you sure that you incuded the proper unix-socket in the database configuration?

Don’t forget that you should edit config/console.php !

I forgot that the other day and was stupefied when Yii picked a sqlite database when I’ve set it all up to use MySQL! :lol:

Easy to forget.

Hello

on my mac after executing yiic shell

i get the full PHP code

but webapp demo works

got a similar case, but it is on a warning on using date() without setting up the timezone first.

Warning: date(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Los_Angeles’ for ‘PST/-8.0/no DST’ instead in /Applications/MAMP/htdocs/yii/framework/views/exception.php on line 217

similar to the call of date() at this line: /Applications/MAMP/htdocs/demo/protected/views/layouts/main.php(48)

the error is documented on the php.net manual section: function.date-default-timezone-set.php

so just add:

date_default_timezone_set(‘America/Los_Angeles’);

at those two lines mentioned above fixed the issue.

Thanks man! This has saved my life!