Using bake on shared hosting Cakephp - cakephp

I'm trying to get bake working on my subdomain which is under shared hosting.
Is there a way we can get this working? I know how to connect to server via ssh shell but then what do I do after that?

First cd to the directory where the cake script is. On a Linux webserver, this would probably be something like ~/cake/console/, if you've put the CakePHP libs outside your web-accessible directories. If you've put everything into your web directory you'll probably have to go somewhere like ~/www/cake/console/.
Then simply type ./cake bake and take it from there.
You shouldn't have to do anything with environment variables. This is only necessary if you want to be able to run the cake console from any directory. I find it less of a hassle to just cd into the cake console's directory and run it using ./cake.

same as local machine cd <path_to_console> cake
if you do not know path_to_console ask for host support,
also path_to_console may be in environment path then just use cake in all dirs

Related

How to create models in cakephp using the command prompt

I'm using cakephp to develop my project and I want to create models using the command prompt as that is easier than creating models manually. As I'm using the windows environment.
I edited the path in my computer/advanced settings/environment variable/system variable as below.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin;C:\Program Files\TortoiseSVN\bin;C:\wamp\www\fit or fat\lib\Cake\Console;
(I have renamed my cakephp folder as fit or fat)
But whwn I enter the 'cake bake ' command in cmd I'm getting the error message that cake is not recognized as an internal or external command.
Is there anything else I have to do/
In Windows you need to use cake.bat instead just cake which is for *nix.
Also you can run bake without environment variables setting just do the following
cd "C:\wamp\www\fit or fat"
lib\Cake\Console\cake.bat bake
but you need to setup correct correct path to your php anyway.
If you want to just run bake without any setting do the following
cd "C:\wamp\www\fit or fat"
c:\wamp\php\bin\php.exe lib\Cake\Console\cake.php bake
please check path to your php executable, it can differ from mine c:\wamp\php\bin\php.exe

Cannot get the cakephp 2.3 console running on xampp on Windows 7

I am running a cakePHP app which is located in C:xammp\htdocs\scheduling. I am running it on xampp on Windows 7. I have added the following environment variables:
C:\xampp\htdocs\scheduling\app\Console\;C:\xampp\php;
but still cannot get the cakephp console in operation. When I navigate to C:\xampp\htdocs\scheduling\app and try to get the cake console or cake help, I am given a message that it is not recognized as an internal or external command.
And yes, I did reload the cmd after adding the environment variables.
Its Easy just follow the steps as mentioned below:
put Your PHP Path in environment Variable
Open Command Prompt with Admin priviliges
change directory to C:\xampp\htdocs\your_appname\app\console
Type in " Cake Bake " and run
And You Are ready to go...................Happy Baking...........................
Just reloading the cmd is not enough, you need to either reboot your system or add it once manually before you are ready to reboot:
set Path="%Path%;c:\xampp\htdocs\scheduling\app\Console"
If all else fails, you can always call it in full from your app dir:
Console\cake bake
It's a little bit more typing, but this will work regardless of the Path variable settings.

CakePHP 2.0 - Cake was unable to write to File cache

I'm using CakePHP 2.0 RC-1. After checking out the project from SVN, the application is starting to complain that it can't write cache files to the tmp/cache directory. Since this is local, I know the directory is writeable and I can CLEARLY see that the directories are even filled with files, so the error is a bit strange.
Here are some of the errors I've encountered:
_cake_core_ cache was unable to write 'cake_dev_nb' to File cache
fopen(c:\cake\app\tmp\cache\models\cake_model_default_media) [function.fopen]: failed to open stream: No error [CORE\Cake\Cache\Engine\FileEngine.php, line 127]
No error?! Wth?
Now, if I look in the FileEngine file, at line 127 it reads:
if (!$handle = fopen($this->_File->getPathName(), 'c')) {
return false;
}
By replacing the "c" with "w", no error is encountered and everything works as it should. But, it should not be necessary to modify the core Cake libraries to work around this problem. Let me repeat that on my other computer this works as intended, without editing the core library. Both use the Windows OS and the read/write rights to the tmp/cache-folder is exactly the same.
Edit: Here's a site that experiences the error outputs I'm having locally
Example site found by Googling. Not my site: http://www.12h30.net/credit/
Any suggestions?
Update: Here is why: This is caused if you have a PHP-version that's too low, before 5.2.6, as outlined by "api55" in the comments. Thanks for the reply. Hope this helps you too.
Well, in my case, when I checked my app, it hadn't the /tmp folder. Then I created the structure (/tmp/cache/models, /tmp/cache/persistent) and all worked well. This happened to me maybe git ignore empty folders, so they weren't created.
I had a similar problem, it was because I had chown -R www to the app/tmp directory to get Cake to run "properly" without giving everyone write privileges. Looks like during development the only way to use the console and the web is to give everyone write privileges, or add yourself to the www group perhaps.
Easy solution:
chmod -R 777 app/tmp
or
chown -R username app/tmp
while using the console and
chown -R www app/tmp
when using the web
Just give the right CHMOD (776 works fine for me) to app/tmp
for windows users with the same error/warning: make sure you run the command prompt in elevated mode ;)

Having trouble getting cake bake to work

I've installed the latest version of CakePHP on a Ubuntu 10.10 machine. I was able to run through a beginner tutorial just fine so I think my configuration is close to being correct. I can't get cake bake to completely work though. Below is my session. Things that look like anomolies are in bold. I think I must have one or more small errors in my configuration that are manifesting when running the bake shell. Thanks!
ubuntu#myserver.com:~$ cd /var/www/app
ubuntu#myserver.com:/var/www/app$ ../cake/console/cake bake -app /var/www/app
Failed loading /usr/lib/php5/20090626.so: /usr/lib/php5/20090626.so: cannot open shared object
file: No such file or directory
Welcome to CakePHP v1.3.2 Console
App : app
Path: /var/www/app
Interactive Bake Shell
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
P
What is the full path for this app including the app directory name?
Example:/var/www/app/myapp
[/var/www/app/myapp] > /var/www/app
Bake Project
Skel Directory: /usr/share/php/cake/console/templates/skel
Will be copied to: /var/www/app
Look okay? (y/n/q)
[y] > y
Do you want verbose output? (y/n)
[n] > y
Created: app in /var/www/app
/usr/share/php/cake/console/templates/skel/app_controller.php copied to
/var/www/app/app_controller.php
/usr/share/php/cake/console/templates/skel/app_model.php copied to
/var/www/app/app_model.php
/usr/share/php/cake/console/templates/skel/index.php copied to /var/www/app/index.php
/usr/share/php/cake/console/templates/skel/.htaccess copied to /var/www/app/.htaccess
/usr/share/php/cake/console/templates/skel/app_helper.php copied to /var/www/app/app_helper.php
Creating file /var/www/app/views/pages/home.ctp
File /var/www/app/views/pages/home.ctp exists, overwrite? (y/n/q)
[n] > y
Wrote /var/www/app/views/pages/home.ctp
Welcome page created
Random hash key created for 'Security.salt'
Random seed created for 'Security.cipherSeed'
Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in /var/www/app/webroot/index.php
Could not set permissions on /var/www/app//tmp
chmod -R 0777 /var/www/app//tmp
Interactive Bake Shell
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
q
ubuntu#myserver.com:/var/www/app$
Mark Murphy,
1.
Failed loading /usr/lib/php5/20090626.so: /usr/lib/php5/20090626.so: cannot open shared object
*.so files are shared libraries. I would try to tackle it be (re-) installing the PHP CLI.
2.
Could not set permissions on /var/www/app//tmp
How could the slash creep in twice? Such a folder should not exist.
Edit0:
It is a bit strange, as CakePHP should work right out of the box, but maybe you really should take a look at the specified variable in app/webroot/index.php and see if you can change the CAKE_CORE_INCLUDE_PATH so that the superfluous slash vanishes.
Edit1:
For general deployment there is nothing better than this afaik.
Edit2:
cake bake help returns:
-app Absolute/Relative path to your app folder.
Hence you should call either:
cake bake app /var/www/<your_project_name>/ <---- note the trailing slash
or
when in /var/www/ call cake bake app <just_your_project_name>
Edit3:
In a nutshell: You could download the CakePHP tar.gz and unzip it in your /var/www/, then rename the folder (having some weird cakePHP-1234... name) into the name of your application, e.g. missioncontrol. Then in your browser: http://localhost/missioncontrol , proceed as instructed.
This is a very quick method to get going, but you can develop other methods according to your build process.
After you have developed your app and intend to deploy it on a host different than your local machine, use the link provided under edit1.

CakePHP Shell issue

I am just getting started with Cakephp shell and running into issues.
My cake core library is under path d:/libs/cake
My app is setup under d:/servers/htdocs/myapp
I wrote a test shell under d:/servers/htdocs/myapp/vendor/shells
class ReportShell extends Shell {
var $uses = array('Appt');
function main() {
echo $this->Appt->find('first');
}
}
When I try to run this code from d:/servers/htdocs/myapp , It gives me an error
Warning: include_once(d:/servers/htdocs/myapp/config/database.php): failed to open stream: No such file or directory in d:/libs/cake\libs\mode
l\connection_manager.php on line 23
Warning: include_once(): Failed opening 'd:/servers/htdocs/myapp/config/database.php' for inclusion (include_path='.;D:\work\xampp\php\PEAR') in d:/libs/cake\libs\model\connection_manager.php on line 23
Fatal error: ConnectionManager::getDataSource - Non-existent data source default in d:/libs/cake\libs\model\connection_manager.php on line 102
Reason is that it is trying to find database.php under 'd:/servers/htdocs/myapp/config/' and the correct path is 'd:/servers/htdocs/myapp/app/config/database.php'
What am I doing wrong here?
thanks
My app is setup under d:/servers/htdocs/myapp
No, the application directory (holding the config folder) is D:\servers\htdocs\myapp\app\.
Reason is that it is trying to find database.php under 'd:/servers/htdocs/myapp/config/' and the correct path is 'd:/servers/htdocs/myapp/app/config/database.php'
You are in the wrong directory, therefore it can't find your database config.
I wrote a test shell under d:/servers/htdocs/myapp/vendor/shells
Move your shell out of the global vendors folder at D:\servers\htdocs\myapp\vendors\shells to the application's vendors folder at D:\servers\htdocs\myapp\app\vendors\shells instead and try again.
(Note: I'm not actually sure where the global vendors folder should be when you have a setup where the cake and application directories are split from each other, but you definitely have to be in your application directory when running commands and not the myapp directory you're using.)
If you add D:\libs\cake\console\ to your PATH environment variable (remembering to close all cmd.exe processes afterwards) then you will simply be able to execute the following:
D:\servers\htdocs\myapp\app> cake report (from within the application directory)
Otherwise you will need to type the full relative or absolute path to the cake console executable and/or provide CakePHP with the absolute path to the application directory (if you are not in it):
D:\servers\htdocs\myapp\app> ..\..\..\..\libs\cake\console\cake report
D:\servers\htdocs\myapp\app> \libs\cake\console\cake report
D:\libs\cake\console> cake -app D:\servers\htdocs\myapp\app report
D:\> libs\cake\console\cake -app D:\servers\htdocs\myapp\app report
etc...
Hopefully you can see why just adding the correct folder to your PATH makes things a lot easier. :)
Try to run it from within the /app directory or with the -app parameter specified:
cake -app d:/servers/htdocs/myapp/app report
Thanks. Here was the issue
My shell script was under /myapp/vendor/shells which was wrong. It should have been under /myapp/app/vendor/shells. After I moved the file, it worked. Thank you
You should always be in your APP path to execute the cake console.
Your Shell File Should be in ..app/Console/Command/
If your file name is TestShell.php type command app> cake test

Resources