-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
166 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nbproject/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
<?php | ||
|
||
namespace libs8000\consoleutils; | ||
|
||
/** | ||
* libs8000 module definition class | ||
*/ | ||
class Module extends \yii\base\Module | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public $controllerNamespace = 'libs8000\consoleutils\controllers'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
// custom initialization code goes here | ||
} | ||
} | ||
<?php | ||
namespace dmitriyha\Yii2AdvancedTemplateInit; | ||
|
||
/** | ||
* module definition class | ||
*/ | ||
class Module extends \yii\base\Module | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public $controllerNamespace = 'dmitriyha\Yii2AdvancedTemplateInit\controllers'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
// custom initialization code goes here | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
{ | ||
"name": "libs8000/consoleutils", | ||
"description": "Console utilities for the libs8000", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Dmitriy Haralson", | ||
"email": "diharalson@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"yiisoft/yii2": ">=2.0.6" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"libs8000\\consoleutils\\": "" | ||
} | ||
} | ||
} | ||
{ | ||
"name": "dmitriyha/yii2-advanced-template-init", | ||
"description": "Console utility to initialize and reinitialze a Yii2 application", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Dmitriy Haralson", | ||
"email": "diharalson@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"yiisoft/yii2": ">=2.0.6" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"dmitriyha\\Yii2AdvancedTemplateInit\\": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
<?php | ||
|
||
namespace libs8000\consoleutils\controllers; | ||
|
||
use Yii; | ||
|
||
use yii\console\Controller; | ||
use libs8000\consoleutils\widgets\DevelopmentEnvironment; | ||
use libs8000\consoleutils\widgets\ProductionEnvironment; | ||
|
||
/** | ||
* Environemt controller | ||
* | ||
* | ||
**/ | ||
|
||
class EnvironmentController extends Controller | ||
{ | ||
|
||
public function actionDev() | ||
{ | ||
DevelopmentEnvironment::widget(); | ||
} | ||
|
||
public function actionProd() | ||
{ | ||
ProductionEnvironment::widget(); | ||
} | ||
} | ||
<?php | ||
namespace dmitriyha\Yii2AdvancedTemplateInit\controllers; | ||
|
||
use Yii; | ||
|
||
use yii\console\Controller; | ||
use dmitriyha\Yii2AdvancedTemplateInit\widgets\DevelopmentEnvironment; | ||
use dmitriyha\Yii2AdvancedTemplateInit\widgets\ProductionEnvironment; | ||
|
||
/** | ||
* Environemt controller | ||
* | ||
* | ||
**/ | ||
|
||
class EnvironmentController extends Controller | ||
{ | ||
|
||
public function actionDev() | ||
{ | ||
DevelopmentEnvironment::widget(); | ||
} | ||
|
||
public function actionProd() | ||
{ | ||
ProductionEnvironment::widget(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
<?php | ||
namespace libs8000\consoleutils\widgets; | ||
|
||
use Yii; | ||
use yii\base\Widget; | ||
|
||
//the base widget class to set environment files | ||
abstract class BaseEnvironment extends Widget { | ||
public $dbName; | ||
public $dbUser = 'root'; | ||
public $dbPassword = ''; | ||
public $dbHost = 'localhost'; | ||
|
||
public $namespaces = [ | ||
'@common', | ||
'@frontend', | ||
'@backend', | ||
'@console', | ||
]; | ||
|
||
protected $environment; | ||
|
||
public function run(){ | ||
foreach($this->namespaces as $namespace){ | ||
$path = yii::getAlias($namespace); | ||
$configFolder = $path.'/config'; | ||
$folder = str_replace('@','',$namespace); | ||
file_put_contents($configFolder.'/main-local.php', | ||
$this->render( | ||
$this->environment.'/'.$folder.'/config/main-local.php', | ||
[ | ||
'dbName'=>$this->dbName, | ||
'dbUser'=>$this->dbUser, | ||
'dbPassword'=>$this->dbPassword, | ||
'dbHost'=>$this->dbHost, | ||
] | ||
) | ||
); | ||
file_put_contents($configFolder.'/params-local.php',$this->render($this->environment.'/'.$folder.'/config/params-local.php')); | ||
if(!file_exists($path.'/web/index.php') && $namespace !== '@common' && $namespace !== '@console'){ | ||
if(!file_exists($path.'/web/assets')){ | ||
mkdir($path.'/web/assets',755); | ||
mkdir($path.'/runtime',755); | ||
} | ||
file_put_contents($path.'/web/index.php',$this->render($this->environment.'/'.$folder.'/web/index.php')); | ||
} | ||
|
||
} | ||
|
||
return parent::run(); | ||
} | ||
<?php | ||
namespace dmitriyha\Yii2AdvancedTemplateInit\widgets; | ||
|
||
use Yii; | ||
use yii\base\Widget; | ||
|
||
//the base widget class to set environment files | ||
abstract class BaseEnvironment extends Widget { | ||
public $dbName; | ||
public $dbUser = 'root'; | ||
public $dbPassword = ''; | ||
public $dbHost = 'localhost'; | ||
|
||
public $namespaces = [ | ||
'@common', | ||
'@frontend', | ||
'@backend', | ||
'@console', | ||
]; | ||
|
||
protected $environment; | ||
|
||
public function run(){ | ||
foreach($this->namespaces as $namespace){ | ||
$path = yii::getAlias($namespace); | ||
$configFolder = $path.'/config'; | ||
$folder = str_replace('@','',$namespace); | ||
file_put_contents($configFolder.'/main-local.php', | ||
$this->render( | ||
$this->environment.'/'.$folder.'/config/main-local.php', | ||
[ | ||
'dbName'=>$this->dbName, | ||
'dbUser'=>$this->dbUser, | ||
'dbPassword'=>$this->dbPassword, | ||
'dbHost'=>$this->dbHost, | ||
] | ||
) | ||
); | ||
file_put_contents($configFolder.'/params-local.php',$this->render($this->environment.'/'.$folder.'/config/params-local.php')); | ||
if(!file_exists($path.'/web/index.php') && $namespace !== '@common' && $namespace !== '@console'){ | ||
if(!file_exists($path.'/web/assets')){ | ||
mkdir($path.'/web/assets',755); | ||
mkdir($path.'/runtime',755); | ||
} | ||
file_put_contents($path.'/web/index.php',$this->render($this->environment.'/'.$folder.'/web/index.php')); | ||
} | ||
|
||
} | ||
|
||
return parent::run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?php | ||
namespace libs8000\consoleutils\widgets; | ||
//use yii\base\Widget; | ||
|
||
class DevelopmentEnvironment extends BaseEnvironment { | ||
|
||
protected $environment = 'dev'; | ||
|
||
<?php | ||
namespace dmitriyha\Yii2AdvancedTemplateInit\widgets; | ||
//use yii\base\Widget; | ||
|
||
class DevelopmentEnvironment extends BaseEnvironment { | ||
|
||
protected $environment = 'dev'; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?php | ||
namespace libs8000\consoleutils\widgets; | ||
|
||
//production environment setting widget | ||
class ProductionEnvironment extends BaseEnvironment { | ||
|
||
protected $environment = 'prod'; | ||
|
||
<?php | ||
namespace dmitriyha\Yii2AdvancedTemplateInit\widgets; | ||
|
||
//production environment setting widget | ||
class ProductionEnvironment extends BaseEnvironment { | ||
|
||
protected $environment = 'prod'; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
#!/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', false); | ||
defined('YII_ENV') or define('YII_ENV', 'prod'); | ||
|
||
require(__DIR__ . '/vendor/autoload.php'); | ||
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); | ||
require(__DIR__ . '/common/config/bootstrap.php'); | ||
require(__DIR__ . '/console/config/bootstrap.php'); | ||
|
||
$config = yii\helpers\ArrayHelper::merge( | ||
require(__DIR__ . '/common/config/main.php'), | ||
require(__DIR__ . '/common/config/main-local.php'), | ||
require(__DIR__ . '/console/config/main.php'), | ||
require(__DIR__ . '/console/config/main-local.php') | ||
); | ||
|
||
$application = new yii\console\Application($config); | ||
$exitCode = $application->run(); | ||
exit($exitCode); | ||
#!/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', false); | ||
defined('YII_ENV') or define('YII_ENV', 'prod'); | ||
|
||
require(__DIR__ . '/vendor/autoload.php'); | ||
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); | ||
require(__DIR__ . '/common/config/bootstrap.php'); | ||
require(__DIR__ . '/console/config/bootstrap.php'); | ||
|
||
$config = yii\helpers\ArrayHelper::merge( | ||
require(__DIR__ . '/common/config/main.php'), | ||
require(__DIR__ . '/common/config/main-local.php'), | ||
require(__DIR__ . '/console/config/main.php'), | ||
require(__DIR__ . '/console/config/main-local.php') | ||
); | ||
|
||
$application = new yii\console\Application($config); | ||
$exitCode = $application->run(); | ||
exit($exitCode); |