[英]app/Console/cake vs lib/Console/cake in CakePHP
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 . 我是使用CakePHP刚接触 Shell
,我没注意到有2个cake
Console应用程序:一个在app/Console/cake
,另一个在lib/Console/cake
中,第二个在CakePHP的核心中 。
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. 到目前为止,我已经使用lib/Console/cake bake -app /path/to/app
来烘烤一些MVC类,但是我之前从未使用过app/Console/cake
。 Also lib/Console/cake
is configured in my environment variables . 我的环境变量中还配置了lib/Console/cake
。
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? 注意:我将核心文件夹移动到了另一个目录,所以app/Console/cake
自然不会找到ShellDispatcher
,我应该修改哪一行来设置核心库的新路径?
Are identical, but you should use the one inside app folder: 完全相同,但是您应该在app文件夹中使用一个:
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 在这里查看手册: http : //book.cakephp.org/2.0/en/installation/advanced-installation.html#sharing-cakephp-libraries-with-multiple-applications
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: 可以这样突出显示:
www-data @ dev [ /tmp/cakephp ] (master=)
-> app/Console/cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------
-> 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 路径中的cake
If /tmp/cakephp/lib/Cake/Console/
is in the path: 如果/tmp/cakephp/lib/Cake/Console/
在路径中:
-> 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. 如果始终指定-app
标志,则它们将发挥相同的作用,但是如果例如在同一主机上使用不同版本的CakePHP的多个应用程序,则会发现在路径中使用cake是有问题的。
If you moved the cake folder, the files you need to edit are: 如果您移动cake文件夹,则需要编辑的文件为:
$root
variable/include_path) app / Console / cake.php( $root
变量/ include_path) Only the first will affect cli usage. 只有第一个会影响cli的使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.