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,
-app is a parameter for the cake command:
C:\...\console>cake -app C:\xampp\htdocs\cake\apressblog\app
You can also run cake console without problems, provided you're at the correct path. Try the following:
C:\xampp\htdocs\cake\apressblog\>C:\xampp\htdocs\cake\apressblog\cake\console\cake
or, to save yourself the trouble, add C:\xampp\htdocs\cake\apressblog\cake\console to the %PATH% environmental variable.
Related
I'm using the Encore/Webpack in my Symfony project, but Im having troubles with the installation.
I'm following the official guide: Link to official guide
My project folder:
projectname
---/app
---/assets
/css
/global.scss
/js
/main.js
...
---/node_modules
/.bin
/encore
...
---/web
/build
etc
I was following
Create a new file called webpack.config.js at the root of your
project.
It looks like:
projectname
...
webpack.config.js
I filled it with the example code. Afterwards I wanted to 'build' the assets with the command encore dev on path: projectname\node_modules\.bin
When I do this, I get the following error code:
Running webpack ...
No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.
I have no idea what I'm doing wrong. When I move the webpack.config.js to the .bin folder.. that part works, but than the build doesn't work, because it wants to install the files into .../.bin/build/ which is not correct. I want it into projectname/build like the example.
try this commend it's work for me
install webpack-notifier#^1.6.0 --save-dev
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.
I'm new to Shell using CakePHP and I couldn't notice how there are 2 cake console application: one at app/Console/cake and other in lib/Console/cake being the second one the one in CakePHP's core.
So far, I have used lib/Console/cake bake -app /path/to/app to bake some MVC classes, but I have never used app/Console/cake before. Also lib/Console/cake is configured in my environment variables.
I want to know the difference of these 2, when to use one or another and why.
Note: I moved my core folder to a different directory, so naturally, app/Console/cake wont find ShellDispatcher, which line should I modify to set the new path to core library?
Are identical, but you should use the one inside app folder:
cd app/
./Console/cake bake
To change the default folder structure and config you must edit these files:
/app/webroot/index.php
/app/webroot/test.php
and un-Comment this line putting your core folder location:
// /usr/lib/mylocation
define('CAKE_CORE_INCLUDE_PATH', DS . 'usr' . DS . 'lib' . DS . 'mylocation');
Take a look at the manual here:
http://book.cakephp.org/2.0/en/installation/advanced-installation.html#sharing-cakephp-libraries-with-multiple-applications
The difference
The difference between the two executables is that one derives the app location from the current working directory, and the other is application specific. This can be highlighted like so:
Normal usage:
www-data # dev [ /tmp/cakephp ] (master=)
-> app/Console/cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------
Reference app executable from different path:
-> cd anywhere
-> /tmp/cakephp/app/Console/cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------
Note the app and path did not change.
cake in path
If /tmp/cakephp/lib/Cake/Console/ is in the path:
-> cd anywhere
-> cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : xxx
Path: **anywhere**
---------------------------------------------------------------
Note the app and path vary depending on where you are when executing the command.
If you always specify the -app flag, they will function the same, but you'll find it is problematic to use cake in your path if for example you have multiple applications on the same host using different versions of CakePHP.
Fixing paths
If you moved the cake folder, the files you need to edit are:
app/Console/cake.php ($root variable/include_path)
app/webroot/index.php (ROOT constant)
app/webroot/test.php (ROOT constant)
Only the first will affect cli usage.
I'm having trouble getting the cake console on winows (XAMPP) to see the demo shell
C:\xampp\htdocs\twitter\app\vendors\shells>dir
2011/03/31 21:11 <DIR> .
2011/03/31 21:11 <DIR> ..
2011/03/31 21:16 761 demo.php
2011/03/31 21:01 <DIR> tasks
2011/03/31 21:01 <DIR> templates
I have the demo.php shell in the shell directory.
C:\xampp\htdocs\twitter\app\vendors\shells>cake demo
Error: Class DemoShell could not be loaded.
But the cake console couldn't find it.
C:\xampp\htdocs\twitter\app\vendors\shells>cake
Welcome to CakePHP v1.3.7 Console
---------------------------------------------------------------
Current Paths:
-app: shells
-working: C:\xampp\htdocs\twitter\app\vendors\shells
-root: C:\xampp\htdocs\twitter\app\vendors
-core: C:\xampp\htdocs\twitter
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\twitter\app\vendors\shells>
And it isn't recognised by the console itself. (note the core is reading from the correct directory).
It's probably some silly oversight but any idea what I am doing wrong here?
You should call cake [shell name] from within the app folder: C:\xampp\htdocs\twitter\app\>cake demo.
Please let me know if it works.
Read the error, it does not say 'file not found' it says 'class not found' so it would seem you have named the class incorrectly inside your demo.php shell
Error: Class DemoShell could not be loaded. that is a hint as to what it should be
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