diff --git a/framework/console/Application.php b/framework/console/Application.php index fb579e2..537821c 100644 --- a/framework/console/Application.php +++ b/framework/console/Application.php @@ -126,7 +126,7 @@ class Application extends \yii\base\Application 'message' => 'yii\console\controllers\MessageController', 'help' => 'yii\console\controllers\HelpController', 'migrate' => 'yii\console\controllers\MigrateController', - 'app' => 'yii\console\controllers\CreateController', + 'webapp' => 'yii\console\controllers\WebappController', 'cache' => 'yii\console\controllers\CacheController', ); } diff --git a/framework/console/controllers/CreateController.php b/framework/console/controllers/WebappController.php similarity index 92% rename from framework/console/controllers/CreateController.php rename to framework/console/controllers/WebappController.php index 7bd7fd0..c19eff3 100644 --- a/framework/console/controllers/CreateController.php +++ b/framework/console/controllers/WebappController.php @@ -1,6 +1,6 @@ * @since 2.0 */ -class CreateController extends Controller +class WebappController extends Controller { private $_rootPath; private $_config; /** * @var string custom template path. If specified, templates will be - * searched there additionally to `framework/console/create`. + * searched there additionally to `framework/console/webapp`. */ public $templatesPath; @@ -46,6 +46,16 @@ class CreateController extends Controller } } + public function globalOptions() + { + return array('templatesPath', 'type'); + } + + public function actionIndex() + { + $this->forward('help/index', array('-args' => array('webapp/create'))); + } + /** * Generates Yii application at the path specified via appPath parameter. * @@ -56,7 +66,7 @@ class CreateController extends Controller * @throws \yii\base\Exception if path specified is not valid * @return integer the exit status */ - public function actionIndex($path) + public function actionCreate($path) { $path = strtr($path, '/\\', DIRECTORY_SEPARATOR); if(strpos($path, DIRECTORY_SEPARATOR) === false) { @@ -127,7 +137,7 @@ class CreateController extends Controller */ protected function getDefaultTemplatesPath() { - return realpath(__DIR__.'/../create'); + return realpath(__DIR__.'/../webapp'); } /** diff --git a/framework/console/create/config.php b/framework/console/webapp/config.php similarity index 83% rename from framework/console/create/config.php rename to framework/console/webapp/config.php index 29f0b0b..6a8d28a 100644 --- a/framework/console/create/config.php +++ b/framework/console/webapp/config.php @@ -1,5 +1,5 @@ run(); \ No newline at end of file diff --git a/framework/console/webapp/default/protected/config/main.php b/framework/console/webapp/default/protected/config/main.php new file mode 100644 index 0000000..1e3f981 --- /dev/null +++ b/framework/console/webapp/default/protected/config/main.php @@ -0,0 +1,16 @@ + 'My Web Application', + + 'components' => array( + // uncomment the following to use a MySQL database + /* + 'db' => array( + 'class' => 'yii\db\Connection', + 'dsn' => 'mysql:host=localhost;dbname=testdrive', + 'username' => 'root', + 'password' => '', + ), + */ + ), +); \ No newline at end of file diff --git a/framework/console/webapp/default/protected/controllers/SiteController.php b/framework/console/webapp/default/protected/controllers/SiteController.php new file mode 100644 index 0000000..b47b93c --- /dev/null +++ b/framework/console/webapp/default/protected/controllers/SiteController.php @@ -0,0 +1,15 @@ +render('index', array( + 'name' => 'Qiang', + )); + } +} \ No newline at end of file diff --git a/framework/console/webapp/default/protected/views/layouts/main.php b/framework/console/webapp/default/protected/views/layouts/main.php new file mode 100644 index 0000000..197b4a2 --- /dev/null +++ b/framework/console/webapp/default/protected/views/layouts/main.php @@ -0,0 +1,16 @@ + + +
+ +