How to change the Cake Console in Ubuntu? - php

I have downloaded Cake PHP v2.7.0. Now, I need to change the console path for baking. What command should I use to change the console from current v1.3.0 to v2.7.0. I tried with the following commands
app/Console/cake bake
/var/www/project_name/app/Console/cake.php bake
But, still I am not getting updated with the console. I am using ubuntu OS. What command should I try to change the cake console in my system? When I get into the Console folder and execute the command "cake", I get the following warning:
PHP Warning: /usr/share/php/cake/console/templates/skel/tmp/cache/ is not writable in /usr/share/php/cake/libs/cache/file.php on line 281
PHP Stack trace:
PHP 1. {main}() /usr/share/php/cake/console/cake.php:0
PHP 2. ShellDispatcher->ShellDispatcher() /usr/share/php/cake/console/cake.php:664
PHP 3. ShellDispatcher->_initEnvironment() /usr/share/php/cake/console/cake.php:136
PHP 4. ShellDispatcher->__bootstrap() /usr/share/php/cake/console/cake.php:176
PHP 5. include_once() /usr/share/php/cake/console/cake.php:272
PHP 6. Cache->config() /usr/share/php/cake/console/templates/skel/config/core.php:304
PHP 7. Cache->_buildEngine() /usr/share/php/cake/libs/cache.php:141
PHP 8. FileEngine->init() /usr/share/php/cake/libs/cache.php:166
PHP 9. FileEngine->__active() /usr/share/php/cake/libs/cache/file.php:94
PHP 10. trigger_error() /usr/share/php/cake/libs/cache/file.php:281
Warning: /usr/share/php/cake/console/templates/skel/tmp/cache/ is not writable in /usr/share/php/cake/libs/cache/file.php on line 281
Call Stack:
0.0016 380824 1. {main}() /usr/share/php/cake/console/cake.php:0
0.0174 381144 2. ShellDispatcher->ShellDispatcher() /usr/share/php/cake/console/cake.php:664
0.1012 535216 3. ShellDispatcher->_initEnvironment() /usr/share/php/cake/console/cake.php:136
0.1013 538040 4. ShellDispatcher->__bootstrap() /usr/share/php/cake/console/cake.php:176
0.2275 1716776 5. include_once('/usr/share/php/cake/console/templates/skel/config/core.php') /usr/share/php/cake/console/cake.php:272
0.2300 1898096 6. Cache->config() /usr/share/php/cake/console/templates/skel/config/core.php:304
0.2300 1899448 7. Cache->_buildEngine() /usr/share/php/cake/libs/cache.php:141
0.2340 1956656 8. FileEngine->init() /usr/share/php/cake/libs/cache.php:166
0.2347 1959744 9. FileEngine->__active() /usr/share/php/cake/libs/cache/file.php:94
0.2647 2568904 10. trigger_error() /usr/share/php/cake/libs/cache/file.php:281
Welcome to CakePHP v1.3.14 Console
---------------------------------------------------------------
Current Paths:
-app: Console
-working: /var/www/cakelatest/app/Console
-root: /var/www/cakelatest/app
-core: /usr/share/php
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:
acl [CORE] i18n [CORE]
api [CORE] schema [CORE]
bake [CORE] testsuite [CORE]
console [CORE]
To run a command, type 'cake shell_name [args]'
To get help on a specific command, type 'cake shell_name help'
what am I missing in here?

PHP Warning: /usr/share/php/cake/console/templates/skel/tmp/cache/ is not writable in /usr/share/php/cake/libs/cache/file.php on line 281
Sounds like a permission Problem to me.
can you print here the output of
ls -la /usr/share/php/cake/console/templates/skel/tmp/cache | grep -e " \.$"

When you open the app in the web, cakephp change the /APP/tmp/ folder, you need run the cake command with the www-data user, you can use this command:
sudo www-data php Console/cake.php bake

Related

Cakephp 3.4.14 Exception: Shell class for "Serve" could not be found

here is my shell snip
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/app
$ bin/cake serve
Exception: Shell class for "Serve" could not be found. in [D:\xampp1\htdocs\app\vendor\cakephp\cakephp\src\Console\ShellDispatcher.php, line 327]
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/app
$ cd ../pocketpa-git-clone000000/
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/pocketpa-git-clone000000 (master)
$ bin/cake serve
Exception: Shell class for "Serve" could not be found. in [D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Console\ShellDispatcher.php, line 327]
Warning Error: file_put_contents(D:\xampp1\htdocs\pocketpa-git-clone000000\logs\cli-error.log): failed to open stream: No such file or directory in [D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Log\Engine\FileLog.php, line 133]
PHP Warning: file_put_contents(D:\xampp1\htdocs\pocketpa-git-clone000000\logs\cli-error.log): failed to open stream: No such file or directory in D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Log\Engine\FileLog.php on line 133
last night i shut down my pc and in morning when i restart i am facing this issue
cakephp version 3.4.14
php 5.6.36
and having this problem when wants to start project
Sorry my bad i was messed up with diffferent projects i was working on Laravel Projects and using frequently
php artisan serve
This command will start a development server at http://localhost:8000:
when i come back to CakePhp Project i was messed up and trying
bin\cake serve
command to start local server for cakephp environment http://localhost:8765/
thats make me so much trouble
But the orignal command to run CakePhp Sever on LocalHost is
bin\cake server
here you can get more details https://book.cakephp.org/3.0/en/installation.html#development-server

CakePHP shell script won't run as cron job

I have written a shell script that works perfectly when I test it locally.
bin/cake myshell method
But when I assign it as a crob it's not working. Instead I see the default cake output:
Welcome to CakePHP v3.1.4 Console
---------------------------------------------------------------
App : src
Path: /home/fantastagram/public_html/src/
PHP : 5.6.16
---------------------------------------------------------------
Current Paths:
* app: src
* root: /home/fantastagram/public_html
* core: /home/fantastagram/public_html/vendor/cakephp/cakephp
Available Shells:
[Migrations] migrations
[CORE] i18n, orm_cache, plugin, routes, server
[app] console, instagram
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`
Content-type: text/html; charset=UTF-8
It appears that the two arguments to the script are being ignored. I'm using the cron jobs tool in the cPanel...
What am I doing wrong?
I turned on debugging and found that the script was actually erroring out before it to my parameters. I googled the error and it turned out to be this: Cakephp 3 bin/cake bake - Undefined variable: argv
Tweaked the php.ini config and it worked perfectly.

Yii console commands stopped working on windows after updating from 2.0.3 to 2.0.4

I just updated to Yii 2.0.4 and now my custom console command is not working. However, the default Hello still works.
$ yii hello
hello world
$ yii kw
Error: Unknown command "kw".
$ ls commands
HelloController.php KWController.php
It was working immediately before in 2.0.3.
Strange because it shows up in yii command by itself:
$ yii | grep hello
- hello This command echoes the first argument that you have entered.
hello/index (default) This command echoes what you have entered as the message.
$ yii | grep kw
- kw
I am working on windows.
Problem is probably with the case of your controller name... the kw command would by default look for a KwController.php and won't find a KWController.php if your filesystem is case-sensitive.
You can fix that by either renaming the file, or if you don't want that, manually adding the controller file to the controllerMap in the yii file:
$application = new yii\console\Application($config);
$application->controllerMap['kw'] = 'console\controllers\KWController';

PHPStorm does not read the entire path to the php interpretator

Hi I just installed PHPStorm 5 for the first time to give it a try and I seem to be having a problem in running PHP applications.I have installed xampp and the path to the PHP interpretator has been set to:
D:\Program Files\xampp\php\php.exe
When I try to run I php file I get this error:
"D:\Program Files\xampp\php\php.exe" D:\Program Files\xampp\php\php.exe "D:\Program Files\xampp\htdocs\PHPStorm\Project\index.php"
Could not open input file: D:\Program
Process finished with exit code 1
For some reason it seems that PHPStorm does not read the rest of the path and it stops at D:\Program.
How can I correct this problem besides changing the name of the folder because that would require me to reinstall almost everything on my computer again?
EDIT RUN CONFIGURATION
Look the full command-line:
"D:\Program Files\xampp\php\php.exe" D:\Program Files\xampp\php\php.exe ⤦
"D:\Program Files\xampp\htdocs\PHPStorm\Project\index.php"
You are using the command:
"D:\Program Files\xampp\php\php.exe"
With the following three parameters:
D:\Program
Files\xampp\php\php.exe
"D:\Program Files\xampp\htdocs\PHPStorm\Project\index.php"
You php.exe then tries to open the "file"
D:\Program
and naturally fails. Instead your command should be:
"D:\Program Files\xampp\php\php.exe" c:\path\to\your\script.php
Obviously you did enter the text D:\Program Files\xampp\php\php.exe into too many textboxes as it belongs to. If you're new to PHPStorm I suggest you read the online manual:
Interpreters - PhpStorm 5.0 Web Help
Run/Debug Configuration: PHP Script - PhpStorm 5.0 Web Help
It's also available by pressing F1 when you're in a dialog.
Edit: Clear the field named Interpreator Options

not able to create controller from console : cakephp : showing fatal error

I am trying to create a controller in cakephp(1.3) using console. I am using windows XP and XAMPP.
My current cake console settings below
C:\xampp\htdocs\cake\apressblog\cake\console>cake
♀ Welcome to CakePHP v1.3.4 Console
--------------------------------------------------------------- Current Paths: -app: console
-working: C:\xampp\htdocs\cake\apressblog\cake\console
-root: C:\xampp\htdocs\cake\apressblog\cake
-core: C:\xampp\htdocs\cake\apressblog
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: acl [CORE]
i18n [CORE]
api [CORE]
schema [CORE]
bake [CORE]
testsuite [CORE]
console [CORE]
To run a command, type 'cake
shell_name [args]' To get help on a
specific command, type 'cake
shell_name help'
C:\xampp\htdocs\cake\apressblog\cake\console>-app
c:\xampp '-app' is not recognized as
an internal or external command,
operable program or batch file.
C:\xampp\htdocs\cake\apressblog\cake\console>
what are the path settings I need to set for creating a controller from console ?
I tried to change the app path but, when I type command cake It goes app directory to console,
Could you please help me to solve this issue
when I try to create a controller I am getting the following error :
C:\xampp\htdocs\cake\apressblog\cake\console>cake bake controller news
♀
Welcome to CakePHP v1.3.4 Console
---------------------------------------------------------------
App : console
Path: C:\xampp\htdocs\cake\apressblog\cake\console
---------------------------------------------------------------
Creating file C:\xampp\htdocs\cake\apressblog\cake\console\controllers\news_cont
roller.php
Wrote `C:\xampp\htdocs\cake\apressblog\cake\console\controllers\news_controller.
php`
You can download SimpleTest from http://simpletest.org
Bake is detecting possible fixtures..
Warning: include_once(C:\xampp\htdocs\cake\apressblog\cake\console\config\databa
se.php): failed to open stream: No such file or directory in C:\xampp\htdocs\cak
e\apressblog\cake\libs\model\connection_manager.php on line 23
Warning: include_once(): Failed opening 'C:\xampp\htdocs\cake\apressblog\cake\co
nsole\config\database.php' for inclusion (include_path='.;\xampp\php\PEAR') in C
:\xampp\htdocs\cake\apressblog\cake\libs\model\connection_manager.php on line 23
Fatal error: ConnectionManager::getDataSource - Non-existent data source default
in C:\xampp\htdocs\cake\apressblog\cake\libs\model\connection_manager.php on li
ne 102
C:\xampp\htdocs\cake\apressblog\cake\console>
You need to create your database.php file in the config folder so that Cake knows what database to connect to for the models.
Once you have done this you need to create your database schema and then bake the model for it.
I'd been having the same problem and was googling when I stumbled upon this. I was getting the same 'Warning: include_once...' error as you did.
I figured out this was happening only when I ran the 'cake bake' command from the ..\cake\console\ folder like you did.
So here's what fixed this issue for me. I added path to the console folder to my environment variables. Now I could call the cake bake command from anywhere.
Then I changed directory to your app folder e.g. ...\htdocs\myCakeWebsite\app
Then run 'cake bake' command! It worked fine from then on.
sources: http://www.youtube.com/watch?v=xvJH0wTlRg

Categories