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的引入地址是不同的。