Browse Source

renamed create -> webapp/create, specified global options

tags/2.0.0-beta
Alexander Makarov 12 years ago
parent
commit
a25f870090
  1. 2
      framework/console/Application.php
  2. 20
      framework/console/controllers/WebappController.php
  3. 2
      framework/console/webapp/config.php
  4. 10
      framework/console/webapp/default/index.php
  5. 16
      framework/console/webapp/default/protected/config/main.php
  6. 15
      framework/console/webapp/default/protected/controllers/SiteController.php
  7. 16
      framework/console/webapp/default/protected/views/layouts/main.php
  8. 1
      framework/console/webapp/default/protected/views/site/index.php

2
framework/console/Application.php

@ -126,7 +126,7 @@ class Application extends \yii\base\Application
'message' => 'yii\console\controllers\MessageController', 'message' => 'yii\console\controllers\MessageController',
'help' => 'yii\console\controllers\HelpController', 'help' => 'yii\console\controllers\HelpController',
'migrate' => 'yii\console\controllers\MigrateController', 'migrate' => 'yii\console\controllers\MigrateController',
'app' => 'yii\console\controllers\CreateController', 'webapp' => 'yii\console\controllers\WebappController',
'cache' => 'yii\console\controllers\CacheController', 'cache' => 'yii\console\controllers\CacheController',
); );
} }

20
framework/console/controllers/CreateController.php → framework/console/controllers/WebappController.php

@ -1,6 +1,6 @@
<?php <?php
/** /**
* CreateController class file. * WebappController class file.
* *
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008 Yii Software LLC * @copyright Copyright &copy; 2008 Yii Software LLC
@ -20,14 +20,14 @@ use yii\base\Exception;
* @author Alexander Makarov <sam@rmcreative.ru> * @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class CreateController extends Controller class WebappController extends Controller
{ {
private $_rootPath; private $_rootPath;
private $_config; private $_config;
/** /**
* @var string custom template path. If specified, templates will be * @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; 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. * 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 * @throws \yii\base\Exception if path specified is not valid
* @return integer the exit status * @return integer the exit status
*/ */
public function actionIndex($path) public function actionCreate($path)
{ {
$path = strtr($path, '/\\', DIRECTORY_SEPARATOR); $path = strtr($path, '/\\', DIRECTORY_SEPARATOR);
if(strpos($path, DIRECTORY_SEPARATOR) === false) { if(strpos($path, DIRECTORY_SEPARATOR) === false) {
@ -127,7 +137,7 @@ class CreateController extends Controller
*/ */
protected function getDefaultTemplatesPath() protected function getDefaultTemplatesPath()
{ {
return realpath(__DIR__.'/../create'); return realpath(__DIR__.'/../webapp');
} }
/** /**

2
framework/console/create/config.php → framework/console/webapp/config.php

@ -1,5 +1,5 @@
<?php <?php
/** @var $controller \yii\console\controllers\CreateController */ /** @var $controller \yii\console\controllers\WebappController */
$controller = $this; $controller = $this;
return array( return array(

10
framework/console/webapp/default/index.php

@ -0,0 +1,10 @@
<?php
define('YII_DEBUG', true);
$yii = __DIR__.'/../framework/yii.php';
require $yii;
$config = require dirname(__DIR__).'/protected/config/main.php';
$basePath = dirname(__DIR__).'/protected';
$app = new \yii\web\Application('webapp', $basePath, $config);
$app->run();

16
framework/console/webapp/default/protected/config/main.php

@ -0,0 +1,16 @@
<?php
return array(
'name' => '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' => '',
),
*/
),
);

15
framework/console/webapp/default/protected/controllers/SiteController.php

@ -0,0 +1,15 @@
<?php
use \yii\web\Controller;
/**
* SiteController
*/
class SiteController extends Controller
{
public function actionIndex()
{
echo $this->render('index', array(
'name' => 'Qiang',
));
}
}

16
framework/console/webapp/default/protected/views/layouts/main.php

@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><?php echo $this->context->pageTitle?></title>
</head>
<body>
<h1><?php echo $this->context->pageTitle?></h1>
<div class="content">
<?php echo $content?>
</div>
<div class="footer">
<?php echo \Yii::powered()?>
</div>
</body>
</html>

1
framework/console/webapp/default/protected/views/site/index.php

@ -0,0 +1 @@
Hello, <?php echo $name?>!
Loading…
Cancel
Save