yii的comand模式使用composer的问题

yii的web模式,也就是平常说的网页请求如 :www.location/user/login

这种就是web模式;

而,php /www/wwwroot/yii_customer_kafka/scan/protected/yiic test 这种就是命令行模式

特别需要注意的是,这两个模式的环境基本是分开的。不止体现在web模式的配置文件时main.php,而命令行模式的配置文件时console.php配置文件这一点上。还体现在入口文件不同。

web模式的入口文件 :实在项目下的index.php。如果项目想要使用composer一般会加在这里。

如:

header("Content-Type:text/html;charset=utf-8");
// change the following paths if necessary
$yii = dirname(__FILE__) . './../yii/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php';
defined('YII_ENV') or define('YII_ENV','product');
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', false);
// specify how many levels of call stack should be shown in each log message
//defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
defined('CONFIG_PATH') or define('CONFIG_PATH', dirname(__FILE__) . '/protected/config/');
$globals = dirname(__FILE__) . '/protected/support/helpers.php';
include __DIR__ . "/protected/extensions/phpExcel/PHPExcel.php";
require_once($globals);
require_once($yii);
require './../vendor/autoload.php';
Yii::createWebApplication($config)->run();

但是:如果命令行模式则在yiic.php:

$yiic = dirname(__FILE__).'/../../yii/framework/yiic.php';
$config = dirname(__FILE__) . '/config/console.php';
$composer=dirname(__FILE__).'/../../vendor/autoload.php';
$globals = dirname(__FILE__) . '/support/helpers.php';
require_once($globals);
require_once ($composer);

require_once($yiic);

注意:这里的composer的引入地址是不同的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值