在cakephp 2.0中运行插件的shell [英] Run plugin's shell in cakephp 2.0
问题描述
我创建了一个新的CakePHP 2.0应用程序,并想运行一个插件的shell。
I have created a new CakePHP 2.0 app and want to run a plugin's shell.
<?php
// app\Plugin\Tmaker\Vendors\Shells\TmakerShell.php
class TmakerShell extends Shell {
}
但是,从命令行运行 Console / cake
时看不到它。
However, I can't see it when running Console/cake
from the command-line.
请告诉我我错过了什么?
Please advise my what I have missed?
推荐答案
=https://github.com/cakephp/docs/blob/master/en/console-and-shells.rst>最新文档,shell的路径已更改为应用程序/ console / Command /
According to the latest documentation, the path for shells has changed to app/Console/Command/
.
将shell移动到以下位置: app / Plugin / Tmaker / Command / TmakerShell.php
(不确定插件目录名是否在CakePHP 2.0中是驼峰式的,但它似乎工作方式不同。)
Move your shell to the following location: app/Plugin/Tmaker/Console/Command/TmakerShell.php
(not sure if plugin directory names are camel-cased in CakePHP 2.0, but it seems to work either way.)
<?php
class TmakerShell extends Shell {
public function main() {
$this->out('It works!');
}
}
$ b $ p
由于CakePHP 2.0需要手动加载插件还需要通过添加 CakePlugin :: loadAll();
或<$ c>更新 app / Config / bootstrap.php
$ c> CakePlugin :: load('Tmaker');
As CakePHP 2.0 requires you to load plugins manually, you also need to update app/Config/bootstrap.php
by adding CakePlugin::loadAll();
or CakePlugin::load('Tmaker');
to the last line.
你应该能够访问你的shell命令行。在Windows中看起来像这样:
You should then be able to access your shell from the command-line. It looks like this in Windows:
C:\xampplite\htdocs\cake2\app>..\lib\Cake\Console\cake Tmaker.tmaker
Welcome to CakePHP v2.0.0-beta Console
---------------------------------------------------------------
App : app
Path: C:\xampplite\htdocs\cake2\app\
---------------------------------------------------------------
It works!
这篇关于在cakephp 2.0中运行插件的shell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!