Skip to content

Commit 40dca95

Browse files
committed
add console app
1 parent 2b32e62 commit 40dca95

File tree

8 files changed

+73
-6
lines changed

8 files changed

+73
-6
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ phpunit.phar
2828

2929

3030
# env vars
31-
.env
31+
.env
32+
33+
# composer
34+
composer.lock

composer.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
"yiisoft/yii2-swiftmailer": "*",
2020
"vlucas/phpdotenv": "~1.0@dev",
2121
"nullref/yii2-useful": "dev-master",
22-
"nullref/yii2-core": "dev-master",
23-
"nullref/yii2-product": "dev-master",
2422
"composer/composer": "~1.0@dev",
25-
"bower-asset/startbootstrap-sb-admin-2": "dev-master"
23+
"nullref/yii2-product": "dev-master"
2624
},
2725
"require-dev": {
2826
"yiisoft/yii2-codeception": "*",

src/config/console.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
$params = require(__DIR__ . '/params.php');
4+
$modules = require(__DIR__ . '/modules.php');
5+
36
return [
4-
//@TODO
7+
'id' => 'console-app',
8+
'basePath' => dirname(__DIR__),
9+
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
10+
'runtimePath' => dirname(dirname(__DIR__)) . '/runtime',
11+
'bootstrap' => ['log', 'core'],
12+
'modules' => $modules,
13+
'params' => $params,
514
];

src/config/modules.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
return [
44
'core' => ['class' => 'nullref\core\Module'],
5-
5+
'product' => ['class' => 'nullref\product\Module'],
66
];

src/views/site/index.php

+5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<?php
2+
use yii\helpers\Url;
23

34
/* @var $this yii\web\View */
45
$this->title = Yii::$app->name;
56
?>
67
<div class="site-index">
78
<h1>Hello world</h1>
9+
<a href="<?= Url::to(['/core/admin']) ?>">Admin</a>
810
<pre>
11+
<?php print_r(Yii::$app->modules) ?>
12+
13+
914
</pre>
1015
</div>

web/.htaccess

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RewriteEngine on
2+
RewriteCond %{REQUEST_FILENAME} !-f
3+
RewriteCond %{REQUEST_FILENAME} !-d
4+
RewriteRule ^([^?]*)$ /index.php?r=$1 [NC,L,QSA]

yii

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/**
4+
* Yii console bootstrap file.
5+
*
6+
* @link http://www.yiiframework.com/
7+
* @copyright Copyright (c) 2008 Yii Software LLC
8+
* @license http://www.yiiframework.com/license/
9+
*/
10+
11+
defined('YII_DEBUG') or define('YII_DEBUG', true);
12+
13+
// fcgi doesn't have STDIN and STDOUT defined by default
14+
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
15+
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
16+
17+
require(__DIR__ . '/vendor/autoload.php');
18+
19+
Dotenv::load(__DIR__);
20+
Dotenv::required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS','YII_DEBUG']);
21+
22+
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
23+
24+
$config = require(__DIR__ . '/src/config/console.php');
25+
26+
$application = new yii\console\Application($config);
27+
$exitCode = $application->run();
28+
exit($exitCode);

yii.bat

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@echo off
2+
3+
rem -------------------------------------------------------------
4+
rem Yii command line bootstrap script for Windows.
5+
rem
6+
rem @author Qiang Xue <[email protected]>
7+
rem @link http://www.yiiframework.com/
8+
rem @copyright Copyright (c) 2008 Yii Software LLC
9+
rem @license http://www.yiiframework.com/license/
10+
rem -------------------------------------------------------------
11+
12+
@setlocal
13+
14+
set YII_PATH=%~dp0
15+
16+
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
17+
18+
"%PHP_COMMAND%" "%YII_PATH%yii" %*
19+
20+
@endlocal

0 commit comments

Comments
 (0)