views:

159

answers:

2

I have been struggling to get my CakePHP site working on a Godaddy "grid hosting" account. My cake app is setup is hosted from a subdirectory on the account, and can be accessed via a subdomain. I had to adjust my .htaccess files to get this working, and now I need to get the CakePHP console working in this environment.

I have the same cake application setup on an Ubuntu server which is hosted on Amazon's EC2 service. Basically a plain out of the box Ubuntu LAMP setup. The CakePHP console works as expected in this environment.

When I try to run the console on Godaddy I get the following message:

CakePHP Console: This file has been loaded incorrectly and cannot continue.Please make sure that /cake/console is in your system path,and check the manual for the correct usage of this command.(http://manual.cakephp.org/)

I've started to add in some debugging code in cake/console/cake.php to find out what's going on. On the godaddy site, when I echo out print_r($this->args) at line 183 I find the array is empty. When I do this on my Ubuntu EC2 instance I get this:

Array ( [0] => /var/www/www.directory.sdcweb.org/htdocs/cake/console/cake.php )

It looks like godaddy's command-line PHP isn't passing through the bash shell command line arguments. Does anybody have some advice as to how I might get the CakePHP console working on Godaddy?

The bash script which invokes the Cake shell contains the following

LIB=${0/%cake/}
APP=`pwd`

exec php -q ${LIB}cake.php -working "${APP}" "$@"

exit;

I am thinking that modifying this script may solve the problem.

A: 

"Please make sure that /cake/console is in your system path."

This is grid hosting so I'm assuming you have a .bashrc file which you can edit. First you need to know the absolute path to your cake sub-directory then use vim or nano to edit your .bashrc

PATH=$PATH:/absolute/path/to/cake/console

Then you can log out and log back in and you should be able to type cake bake from anywhere and it should fix the error your getting (run it from your app directory so it can find your database.php).

Failing a .bashrc file you can export the variable temporarily but you will have to type it every time you log in.

rich97
seems like my PATH is correct. when i echo PATH in the cmd line it looks correct, and i can run the cake command from any directory, always getting that "This file has been loaded incorrectly" message.
the0ther
A: 

in the cake shell script (cake/console/cake) change

exec php -q ${LIB}cake.php -working "${APP}" "$@"

to

exec php -q -d register_argc_argv=1 ${LIB}cake.php -working "${APP}" "$@"

after this I found out that calling php like this happened to run the PHP 4 CLI. to fix this here is the final bash script that I am using to invoke PHP 5 on my shared Godaddy hosting

exec /web/cgi-bin/php5 -q -d register_argc_argv=1 ${LIB}cake.php -working "${APP}" "$@"

if you setup a php-based cron job through their hosting control panel, you will find the php command invoked is actually to this php5 executable.

the0ther