简体   繁体   English

CakePHP中的app / Console / cake vs lib / Console / cake

[英]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 区别

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 路径中的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是有问题的。

Fixing paths 固定路径

If you moved the cake folder, the files you need to edit are: 如果您移动cake文件夹,则需要编辑的文件为:

  • app/Console/cake.php ( $root variable/include_path) app / Console / cake.php( $root变量/ include_path)
  • app/webroot/index.php (ROOT constant) app / webroot / index.php(ROOT常数)
  • app/webroot/test.php (ROOT constant) app / webroot / test.php(ROOT常数)

Only the first will affect cli usage. 只有第一个会影响cli的使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Google App Engine上处理来自Cake Console(cakephp console)的队列 - handle Queues from cake console (cakephp console) on google app engine 在生产中指向lib / Cake / Console / Templates / skel / View / Pages / home.ctp的CakePHP应用 - CakePHP app pointing to lib/Cake/Console/Templates/skel/View/Pages/home.ctp in production 蛋糕PHP。 应用程序/控制台/蛋糕:root 用户的权限被拒绝 - CakePHP. app/Console/cake: Permission denied for root user CakePHP Gurus:控制台蛋糕命令没有正确找到-app路径? - CakePHP Gurus: Console cake command not finding -app path correctly? 无法烘烤 CakePHP - 为 cake/console/cake 设置 chmod +x 时权限被拒绝 - 在 NTFS 安装的分区上 - cannot bake CakePHP - permission denied while setting chmod +x for cake/console/cake - on NTFS mounted partition CakePHP 3:执行控制台命令会显示“未知命令” cake hello”错误 - CakePHP 3: Executing console command gives 'Unknown Command `cake hello`' error cake console 2.2.1:烘烤错误 - cake console 2.2.1: Bake errors 在控制台中启动蛋糕烘烤时出现问题 - Problem starting cake bake in console 如何在Ubuntu中更改Cake Console? - How to change the Cake Console in Ubuntu? 蛋糕烘烤控制台错误:数据库连接丢失 - cake bake console error:Database connection missing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM