mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-16 14:29:30 +08:00
Renamed yiic to yii.
Added console command support to the bootstrap app.
This commit is contained in:
29
apps/bootstrap/protected/commands/HelloController.php
Normal file
29
apps/bootstrap/protected/commands/HelloController.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @link http://www.yiiframework.com/
|
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
|
* @license http://www.yiiframework.com/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace app\commands;
|
||||||
|
use yii\console\Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This command echos what the first argument that you have entered.
|
||||||
|
*
|
||||||
|
* This command is provided as an example for you to learn how to create console commands.
|
||||||
|
*
|
||||||
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
class HelloController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This command echos what you have entered as the message.
|
||||||
|
* @param string $message the message to be echoed.
|
||||||
|
*/
|
||||||
|
public function actionIndex($message = 'hello world')
|
||||||
|
{
|
||||||
|
echo $message;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
apps/bootstrap/protected/config/console.php
Normal file
26
apps/bootstrap/protected/config/console.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'id' => 'bootstrap-console',
|
||||||
|
'basePath' => dirname(__DIR__),
|
||||||
|
'preload' => array('log'),
|
||||||
|
'controllerPath' => dirname(__DIR__) . '/commands',
|
||||||
|
'controllerNamespace' => 'app\commands',
|
||||||
|
'modules' => array(
|
||||||
|
),
|
||||||
|
'components' => array(
|
||||||
|
'cache' => array(
|
||||||
|
'class' => 'yii\caching\FileCache',
|
||||||
|
),
|
||||||
|
'log' => array(
|
||||||
|
'class' => 'yii\logging\Router',
|
||||||
|
'targets' => array(
|
||||||
|
array(
|
||||||
|
'class' => 'yii\logging\FileTarget',
|
||||||
|
'levels' => array('error', 'warning'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'params' => require(__DIR__ . '/params.php'),
|
||||||
|
);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'id' => 'hello',
|
'id' => 'bootstrap',
|
||||||
'basePath' => dirname(__DIR__),
|
'basePath' => dirname(__DIR__),
|
||||||
'preload' => array('log'),
|
'preload' => array('log'),
|
||||||
'modules' => array(
|
'modules' => array(
|
||||||
@@ -33,7 +33,5 @@ return array(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'params' => array(
|
'params' => require(__DIR__ . '/params.php'),
|
||||||
'adminEmail' => 'admin@example.com',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|||||||
5
apps/bootstrap/protected/config/params.php
Normal file
5
apps/bootstrap/protected/config/params.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'adminEmail' => 'admin@example.com',
|
||||||
|
);
|
||||||
23
apps/bootstrap/protected/yii
Normal file
23
apps/bootstrap/protected/yii
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Yii console bootstrap file.
|
||||||
|
*
|
||||||
|
* @link http://www.yiiframework.com/
|
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
|
* @license http://www.yiiframework.com/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||||
|
|
||||||
|
// fcgi doesn't have STDIN defined by default
|
||||||
|
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
|
||||||
|
|
||||||
|
$frameworkPath = __DIR__ . '/../../../yii';
|
||||||
|
|
||||||
|
require($frameworkPath . '/Yii.php');
|
||||||
|
|
||||||
|
$config = require(__DIR__ . '/config/console.php');
|
||||||
|
|
||||||
|
$application = new yii\console\Application($config);
|
||||||
|
$application->run();
|
||||||
@@ -17,6 +17,6 @@ set YII_PATH=%~dp0
|
|||||||
|
|
||||||
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
|
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
|
||||||
|
|
||||||
"%PHP_COMMAND%" "%YII_PATH%yiic" %*
|
"%PHP_COMMAND%" "%YII_PATH%yii" %*
|
||||||
|
|
||||||
@endlocal
|
@endlocal
|
||||||
@@ -19,6 +19,7 @@ use yii\caching\Cache;
|
|||||||
*/
|
*/
|
||||||
class CacheController extends Controller
|
class CacheController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
$this->forward('help/index', array('-args' => array('cache/flush')));
|
$this->forward('help/index', array('-args' => array('cache/flush')));
|
||||||
|
|||||||
5
yii/yiic.php → yii/yii
Normal file → Executable file
5
yii/yiic.php → yii/yii
Normal file → Executable file
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Yii console bootstrap file.
|
* Yii console bootstrap file.
|
||||||
@@ -15,8 +16,8 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
|
|||||||
require(__DIR__ . '/Yii.php');
|
require(__DIR__ . '/Yii.php');
|
||||||
|
|
||||||
$application = new yii\console\Application(array(
|
$application = new yii\console\Application(array(
|
||||||
'id' => 'yiic',
|
'id' => 'yii-console',
|
||||||
'basePath' => __DIR__ . '/console',
|
'basePath' => __DIR__ . '/console',
|
||||||
'controllerPath' => '@yii/console/controllers',
|
'controllerPath' => '@yii/console/controllers',
|
||||||
));
|
));
|
||||||
$application->run();
|
$application->run();
|
||||||
22
yii/yii.bat
Normal file
22
yii/yii.bat
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
rem -------------------------------------------------------------
|
||||||
|
rem Yii command line script for Windows.
|
||||||
|
rem
|
||||||
|
rem This is the bootstrap script for running yiic on Windows.
|
||||||
|
rem
|
||||||
|
rem @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
|
rem @link http://www.yiiframework.com/
|
||||||
|
rem @copyright Copyright © 2012 Yii Software LLC
|
||||||
|
rem @license http://www.yiiframework.com/license/
|
||||||
|
rem -------------------------------------------------------------
|
||||||
|
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
set YII_PATH=%~dp0
|
||||||
|
|
||||||
|
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
|
||||||
|
|
||||||
|
"%PHP_COMMAND%" "%YII_PATH%yii" %*
|
||||||
|
|
||||||
|
@endlocal
|
||||||
13
yii/yiic
13
yii/yiic
@@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/env php
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Yii command line script for Unix/Linux.
|
|
||||||
*
|
|
||||||
* This is the bootstrap script for running yiic on Unix/Linux.
|
|
||||||
*
|
|
||||||
* @link http://www.yiiframework.com/
|
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
|
||||||
* @license http://www.yiiframework.com/license/
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once(__DIR__ . '/yiic.php');
|
|
||||||
Reference in New Issue
Block a user