How to check Cakephp version from command line? - cakephp

I am using Cakephp 3.x but i want to know the exact version number using command line ? is there any command available which can show us the correct version which we are using in our application ?
i know we can use this echo Configure::version(); to check version using code, i was just curious to know if i can come to know the same thing using command line interface only..
FYI, i have windows 7 as OS, xampp as server with composer and other stuff installed in my cakephp application ..
Command for any OS (ubuntu,windows) will be welcomed to come to know about it ..
Thanks

According to their documentation for version 3.x , this is how you can do this. Shells, Tasks & Console Tools
In which they have mentioned to go to directory first using command line tool and then by typing bin/cake Something like this
cd /path/to/app
bin/cake
And in response you will be able to see not only CakePHP's current version but also PHP's current version and few more information.
Welcome to CakePHP v3.0.0 Console
---------------------------------------------------------------
App : App
Path: /Users/markstory/Sites/cakephp-app/src/
---------------------------------------------------------------
Current Paths:
-app: src
-root: /Users/markstory/Sites/cakephp-app
-core: /Users/markstory/Sites/cakephp-app/vendor/cakephp/cakephp
Changing Paths:
Your working path should be the same as your application path. To change your path use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp
Available Shells:
[Bake] bake
[Migrations] migrations
[CORE] i18n, orm_cache, plugin, routes, server
[app] behavior_time, console, orm
To run an app or core command, type cake shell_name [args]
To run a plugin command, type cake Plugin.shell_name [args]
To get help on a specific command, type cake shell_name --help
Also I am not so sure this will work for older version than CakePHP 3.x as I have tried this in version 3.x only.. so please take a note on that too.

Because it doens't show the version when simply typing bin/cake in the project forlder, I also recommend this approach:
Browse to your project forlder
continue browsing to the bin forlder ( cd bin)
then type cake version
That works for me and it shown 3.5.6
Also I recommend including PHP in the system or user path if so you can type php -version anywhere in the prompt to get your php version.

Related

How can I install cakephp2 in 2022?

can anyone tell me how can I install cakephp 2 in 2022 I tried many ways to install it I also have its zip file which I extract it and when I tried to run it it shows.
Fatal Error
Error: Cannot use 'String' as class name as it is reserved
File: E:\xampp\htdocs\cakephp2.3\lib\Cake\Utility\String.php
Line: 27
Notice: If you want to customize this error message, create app\View\Errors\fatal_error.ctp
CakePHP 2 needs php5
since Version 2.8 you can use php70
php71 is possible but you need to install mcrypt seperatly.
Its possible to run a CakePHP 2.8 on php72 with some core hacks. But i wouldn't recommend this.
I got my answer we can download its zip file from github and copy its file in htdocs folder and run it without an issue. By the way I downloaded cakephp 2.10. and it is also running in xampp with php version 8. If in your system it is not running then try to use xampp with php version 7.

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

Baking in cakePHP 2 in windows 7

I am new to the cakePHP and first starting to bake so I face this problem when following a tutorial and do the following:
Add paths to php and cakePHP
Run the CMD and type "cake" and get the following message:
Welcome to CakePHP v2.2.3 Console
---------------------------------------------------------------
App : C:
Path: C:\
---------------------------------------------------------------
Current Paths:
-app: C:
-working: C:
-root: C:
-core: C:\xampp\cake\lib
Changing Paths:
Your working path should be the same as your application path to change your pat
h use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp
Available Shells:
[CORE] acl, api, bake, command_list, console, i18n, schema, test, testsuite, upg
rade
To run an app or core command, type cake shell_name [args]
To run a plugin command, type cake Plugin.shell_name [args]
To get help on a specific command, type cake shell_name --help
3.I type in the path where the app that's being developed is saved, that is:C:\xampp\htcdocs\blog
I have tried to add all possible paths like
C:...blog\app,
C:...blog\app\console,
C:...blog\lib\cake\console,
but I still get the message that the system cannot find the path specified.
I have been looking for the solution for couple of hours now and could only find it for the previous versions of cakePHP or any other OS but Windows 7.
You may want to set your path to folder/app/console of your project. Also to the folder where php.exe resides. This is the way i've set mine and works for me.
Try typing cake help in cmd, it should show cake help file.
edit: i have change this answer so everyone can have cake configured ok!
C:\xampp\htdocs\proyecto\app>set PATH=C:\Program Files\Common Files\Microsoft Sh
ared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\win
dows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Windows Live\Shared;C:\Pr
ogram Files\TortoiseSVN\bin;C:\xampp\htdocs\proyecto\app\Console;C:\xampp\php;
then from your "project" folder (in my case "proyecto") go to app in a cmd window and type "cake help" it should show something like:
Welcome to CakePHP v2.2.1 Console
App : app
Path: C:\xampp\htdocs\proyecto\app\
Current Paths:
-app: app
-working: C:\xampp\htdocs\proyecto\app
-root: C:\xampp\htdocs\proyecto
-core: C:\xampp\htdocs\proyecto\lib
wich means, everything is good to go!
start the command promt
type cd\ press enter and then cd:/xampp/php press enter
php.exe C:/xampp/htdocs/cakeblog/lib/cake/console/cake.php bake press enter
where “C:/xampp/htdocs/cakeblog/lib/cake/console/cake.php” is the path of bake file.
Have Baking!

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 database migration error

I am using Ubuntu + cakephp 1.3. I am trying the database migration with the help of cakeDC migration plugin. I configured the plugin as per the instructions.
But when i goes to the terminal, goes to the path of the application application_path/app/ dir then fire a command 'cake migration help' it gives me following error,
Hello user,
Welcome to CakePHP v1.2 Console
Current Paths:
-working: /path/to/cake/
-root: /path/to/cake/
-app: /path/to/cake/app/
-core: /path/to/cake/
Changing Paths:
your working path should be the same as your application path
to change your path use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp
Available Shells:
app/vendors/shells/:
- none
vendors/shells/:
- none
cake/console/libs/:
acl
api
bake
console
extract
To run a command, type 'cake shell_name [args]'
To get help on a specific command, type 'cake shell_name help'
Then i followed the steps given in the :
http://book.cakephp.org/view/108/The-CakePHP-Console
$ cake -app /path/to/app
But i am not getting the success. Can anybody help me out from this issue...
Thanks in adavnce.
You're executing cake shell, which is somewhere in your $PATH (type which cake to see which one comes in $PATH first). To run cake shell belonging to your app (version 1.3), execute /path/to/your/application/cake/console/cake (if you're in your /app dir, simply execute ../cake/console/cake) with any options you may need (like -app).

Resources