From c10fe193d2199f9fab6ab6151a405a4abf0ca175 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 16 May 2013 15:42:49 -0400 Subject: [PATCH] Renamed yiic to yii. Added console command support to the bootstrap app. --- .../protected/commands/HelloController.php | 29 +++++++++++++++++++ apps/bootstrap/protected/config/console.php | 26 +++++++++++++++++ apps/bootstrap/protected/config/main.php | 6 ++-- apps/bootstrap/protected/config/params.php | 5 ++++ apps/bootstrap/protected/yii | 23 +++++++++++++++ .../bootstrap/protected/yii.bat | 2 +- yii/console/controllers/CacheController.php | 1 + yii/{yiic.php => yii} | 5 ++-- yii/yii.bat | 22 ++++++++++++++ yii/yiic | 13 --------- 10 files changed, 112 insertions(+), 20 deletions(-) create mode 100644 apps/bootstrap/protected/commands/HelloController.php create mode 100644 apps/bootstrap/protected/config/console.php create mode 100644 apps/bootstrap/protected/config/params.php create mode 100644 apps/bootstrap/protected/yii rename yii/yiic.bat => apps/bootstrap/protected/yii.bat (92%) rename yii/{yiic.php => yii} (89%) mode change 100644 => 100755 create mode 100644 yii/yii.bat delete mode 100755 yii/yiic diff --git a/apps/bootstrap/protected/commands/HelloController.php b/apps/bootstrap/protected/commands/HelloController.php new file mode 100644 index 0000000000..16f5f741a5 --- /dev/null +++ b/apps/bootstrap/protected/commands/HelloController.php @@ -0,0 +1,29 @@ + + * @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; + } +} \ No newline at end of file diff --git a/apps/bootstrap/protected/config/console.php b/apps/bootstrap/protected/config/console.php new file mode 100644 index 0000000000..df96023586 --- /dev/null +++ b/apps/bootstrap/protected/config/console.php @@ -0,0 +1,26 @@ + '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'), +); diff --git a/apps/bootstrap/protected/config/main.php b/apps/bootstrap/protected/config/main.php index a1e3678e1b..f6813e06cd 100644 --- a/apps/bootstrap/protected/config/main.php +++ b/apps/bootstrap/protected/config/main.php @@ -1,7 +1,7 @@ 'hello', + 'id' => 'bootstrap', 'basePath' => dirname(__DIR__), 'preload' => array('log'), 'modules' => array( @@ -33,7 +33,5 @@ return array( ), ), ), - 'params' => array( - 'adminEmail' => 'admin@example.com', - ), + 'params' => require(__DIR__ . '/params.php'), ); diff --git a/apps/bootstrap/protected/config/params.php b/apps/bootstrap/protected/config/params.php new file mode 100644 index 0000000000..1e197d0632 --- /dev/null +++ b/apps/bootstrap/protected/config/params.php @@ -0,0 +1,5 @@ + 'admin@example.com', +); \ No newline at end of file diff --git a/apps/bootstrap/protected/yii b/apps/bootstrap/protected/yii new file mode 100644 index 0000000000..df58e581e6 --- /dev/null +++ b/apps/bootstrap/protected/yii @@ -0,0 +1,23 @@ +#!/usr/bin/env php +run(); \ No newline at end of file diff --git a/yii/yiic.bat b/apps/bootstrap/protected/yii.bat similarity index 92% rename from yii/yiic.bat rename to apps/bootstrap/protected/yii.bat index c63fc815d4..18bb296a8e 100644 --- a/yii/yiic.bat +++ b/apps/bootstrap/protected/yii.bat @@ -17,6 +17,6 @@ set YII_PATH=%~dp0 if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe -"%PHP_COMMAND%" "%YII_PATH%yiic" %* +"%PHP_COMMAND%" "%YII_PATH%yii" %* @endlocal \ No newline at end of file diff --git a/yii/console/controllers/CacheController.php b/yii/console/controllers/CacheController.php index b171780341..8ba781fa2f 100644 --- a/yii/console/controllers/CacheController.php +++ b/yii/console/controllers/CacheController.php @@ -19,6 +19,7 @@ use yii\caching\Cache; */ class CacheController extends Controller { + public function actionIndex() { $this->forward('help/index', array('-args' => array('cache/flush'))); diff --git a/yii/yiic.php b/yii/yii old mode 100644 new mode 100755 similarity index 89% rename from yii/yiic.php rename to yii/yii index 7cd0c40289..54fa9dee0e --- a/yii/yiic.php +++ b/yii/yii @@ -1,3 +1,4 @@ +#!/usr/bin/env php 'yiic', + 'id' => 'yii-console', 'basePath' => __DIR__ . '/console', 'controllerPath' => '@yii/console/controllers', )); -$application->run(); +$application->run(); \ No newline at end of file diff --git a/yii/yii.bat b/yii/yii.bat new file mode 100644 index 0000000000..18bb296a8e --- /dev/null +++ b/yii/yii.bat @@ -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 +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 \ No newline at end of file diff --git a/yii/yiic b/yii/yiic deleted file mode 100755 index d35d26271a..0000000000 --- a/yii/yiic +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env php -