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
24 changed files
with
1,269 additions
and
10 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 |
---|---|---|
@@ -1 +1,5 @@ | ||
/vendor | ||
/vendor | ||
|
||
/*/*.pid | ||
/*/*.log | ||
session_mm_*.sem |
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,25 @@ | ||
|
||
default: | ||
@echo "The following commands are available:" | ||
@echo "" | ||
@echo " make start start PHP built-in webserver" | ||
@echo " make stop stop PHP built-in webserver" | ||
|
||
# start PHP built-in webserver | ||
start: | ||
@echo "Starting server for api" | ||
cd api && $(MAKE) start | ||
@echo "Starting server for backend" | ||
cd backend && $(MAKE) start | ||
|
||
# stop PHP built-in webserver | ||
stop: | ||
cd api && $(MAKE) stop | ||
cd backend && $(MAKE) stop | ||
|
||
test: | ||
cd api && $(MAKE) test | ||
|
||
clean: stop | ||
|
||
.PHONY: start stop clean test |
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
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,38 @@ | ||
# additional arguments to PHP binary | ||
PHPARGS= | ||
# enable XDEBUG for the test runner | ||
XDEBUG=0 | ||
# enable XDEBUG for the webserver | ||
XDEBUGW=0 | ||
|
||
WEBPORT=8337 | ||
|
||
ifeq ($(XDEBUG),1) | ||
XDEBUGARGS=-dzend_extension=xdebug.so -dxdebug.remote_enable=1 | ||
endif | ||
ifeq ($(XDEBUGW),1) | ||
XDEBUGARGSW=-dzend_extension=xdebug.so -dxdebug.remote_enable=1 | ||
endif | ||
|
||
|
||
current_dir=$(shell pwd) | ||
|
||
default: | ||
|
||
start: stop | ||
@echo "Starting PHP webserver at http://localhost:$(WEBPORT), see php.log for access log." | ||
@echo "" | ||
@echo "Run make stop to stop it." | ||
@echo "" | ||
YII_ENV=dev php $(PHPARGS) $(XDEBUGARGSW) -S localhost:$(WEBPORT) -t web $(current_dir)/router.php >php.log 2>&1 & echo "$$!" > php.pid | ||
|
||
stop: | ||
@echo "Stopping PHP webserver..." | ||
@-if [ -f php.pid ] ; then kill $$(cat php.pid); fi | ||
@rm -f php.pid | ||
@rm -f session_mm_*.sem | ||
|
||
clean: stop | ||
rm -f php.log | ||
|
||
.PHONY: start stop clean |
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,17 @@ | ||
<?php | ||
|
||
if (getenv('YII_ENV')) { | ||
define('YII_ENV', getenv('YII_ENV')); | ||
define('YII_DEBUG', YII_ENV !== 'prod'); | ||
} | ||
|
||
list($pathInfo) = explode('?', $_SERVER["REQUEST_URI"], 2); | ||
|
||
if (is_file(__DIR__ . '/web/' . ltrim($pathInfo, '/'))) { | ||
return false; | ||
} else { | ||
$_SERVER['SCRIPT_NAME'] = '/index.php'; | ||
$_SERVER['PHP_SELF'] = '/index.php'; | ||
$_SERVER['SCRIPT_FILENAME'] = __DIR__ . '/web/index.php'; | ||
include __DIR__ . '/web/index.php'; | ||
} |
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,38 @@ | ||
# additional arguments to PHP binary | ||
PHPARGS= | ||
# enable XDEBUG for the test runner | ||
XDEBUG=0 | ||
# enable XDEBUG for the webserver | ||
XDEBUGW=0 | ||
|
||
WEBPORT=8338 | ||
|
||
ifeq ($(XDEBUG),1) | ||
XDEBUGARGS=-dzend_extension=xdebug.so -dxdebug.remote_enable=1 | ||
endif | ||
ifeq ($(XDEBUGW),1) | ||
XDEBUGARGSW=-dzend_extension=xdebug.so -dxdebug.remote_enable=1 | ||
endif | ||
|
||
|
||
current_dir=$(shell pwd) | ||
|
||
default: | ||
|
||
start: stop | ||
@echo "Starting PHP webserver at http://localhost:$(WEBPORT), see php.log for access log." | ||
@echo "" | ||
@echo "Run make stop to stop it." | ||
@echo "" | ||
YII_ENV=dev php $(PHPARGS) $(XDEBUGARGSW) -S localhost:$(WEBPORT) -t web $(current_dir)/router.php >php.log 2>&1 & echo "$$!" > php.pid | ||
|
||
stop: | ||
@echo "Stopping PHP webserver..." | ||
@-if [ -f php.pid ] ; then kill $$(cat php.pid); fi | ||
@rm -f php.pid | ||
@rm -f session_mm_*.sem | ||
|
||
clean: stop | ||
rm -f php.log | ||
|
||
.PHONY: start stop clean |
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,27 @@ | ||
<?php | ||
|
||
/** | ||
* Main configuration file for the backend application. | ||
* | ||
* Develop environment. | ||
*/ | ||
|
||
$config = array_merge(require(__DIR__ . '/app.php'), [ | ||
'components' => array_merge( | ||
require __DIR__ . '/../../config/components.php', // common config | ||
require __DIR__ . '/../../config/components-dev.php', // common config (env overrides) | ||
require __DIR__ . '/components.php' // backend specific config | ||
), | ||
]); | ||
|
||
// enable Gii module | ||
$config['bootstrap'][] = 'gii'; | ||
$config['modules']['gii'] = [ | ||
'class' => yii\gii\Module::class, | ||
'generators' => [ | ||
// add ApiGenerator to Gii module | ||
'api' => \cebe\yii2openapi\generator\ApiGenerator::class, | ||
], | ||
]; | ||
|
||
return $config; |
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,15 @@ | ||
<?php | ||
|
||
/** | ||
* Main configuration file for the backend application. | ||
* | ||
* Production environment. | ||
*/ | ||
|
||
return array_merge(require(__DIR__ . '/app.php'), [ | ||
'components' => array_merge( | ||
require __DIR__ . '/../../config/components.php', // common config | ||
require __DIR__ . '/../../config/components-prod.php', // common config (env overrides) | ||
require __DIR__ . '/components.php' // backend specific config | ||
), | ||
]); |
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,15 @@ | ||
<?php | ||
|
||
/** | ||
* Main configuration file for the backend application. | ||
* | ||
* Test environment. | ||
*/ | ||
|
||
return array_merge(require(__DIR__ . '/app.php'), [ | ||
'components' => array_merge( | ||
require __DIR__ . '/../../config/components.php', // common config | ||
require __DIR__ . '/../../config/components-test.php', // common config (env overrides) | ||
require __DIR__ . '/components.php' // backend specific config | ||
), | ||
]); |
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,22 @@ | ||
<?php | ||
|
||
/** | ||
* Main configuration file for the backend application. | ||
*/ | ||
|
||
return [ | ||
'id' => 'backend', | ||
|
||
'basePath' => dirname(__DIR__), | ||
'vendorPath' => dirname(__DIR__, 2) . '/vendor', | ||
'runtimePath' => dirname(__DIR__, 2) . '/runtime/backend', | ||
'aliases' => [ | ||
'@bower' => '@vendor/bower-asset', | ||
'@npm' => '@vendor/npm-asset', | ||
], | ||
'controllerNamespace' => 'backend\controllers', | ||
|
||
'bootstrap' => ['log'], | ||
|
||
'params' => require(__DIR__ . '/../../config/params.php'), | ||
]; |
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,48 @@ | ||
<?php | ||
|
||
/** | ||
* component configuration overrides for the backend application. | ||
*/ | ||
|
||
return [ | ||
'request' => [ | ||
'cookieValidationKey' => 'api1337', // TODO this should be dynamic | ||
], | ||
|
||
'urlManager' => [ | ||
'enablePrettyUrl' => true, | ||
'enableStrictParsing' => true, | ||
'showScriptName' => false, | ||
'rules' => require(__DIR__ . '/url-rules.php'), | ||
], | ||
'log' => [ | ||
'traceLevel' => YII_DEBUG ? 3 : 0, | ||
'targets' => [ | ||
[ | ||
'class' => yii\log\FileTarget::class, | ||
'levels' => ['error', 'warning'], | ||
'logFile' => '@logs/backend-app.error.log', | ||
'except' => [ | ||
'yii\web\HttpException*', | ||
], | ||
], | ||
[ | ||
'class' => yii\log\FileTarget::class, | ||
'levels' => ['error', 'warning'], | ||
'logFile' => '@logs/backend-http.error.log', | ||
'categories' => [ | ||
'yii\web\HttpException*', | ||
], | ||
], | ||
[ | ||
'class' => yii\log\FileTarget::class, | ||
'levels' => ['info'], | ||
'logFile' => '@logs/backend-app.info.log', | ||
'logVars' => [], | ||
'except' => [ | ||
'yii\db\*', | ||
], | ||
], | ||
], | ||
], | ||
]; |
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,7 @@ | ||
<?php | ||
|
||
// TODO configure URL rules with autogenerated spec rules | ||
|
||
return [ | ||
'' => 'site/index', | ||
]; |
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,16 @@ | ||
<?php | ||
|
||
namespace backend\controllers; | ||
|
||
use yii\web\Controller; | ||
|
||
/** | ||
* | ||
*/ | ||
class SiteController extends Controller | ||
{ | ||
public function actionIndex() | ||
{ | ||
return $this->render('index'); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
if (getenv('YII_ENV')) { | ||
define('YII_ENV', getenv('YII_ENV')); | ||
define('YII_DEBUG', YII_ENV !== 'prod'); | ||
} | ||
|
||
list($pathInfo) = explode('?', $_SERVER["REQUEST_URI"], 2); | ||
|
||
if (is_file(__DIR__ . '/web/' . ltrim($pathInfo, '/'))) { | ||
return false; | ||
} else { | ||
$_SERVER['SCRIPT_NAME'] = '/index.php'; | ||
$_SERVER['PHP_SELF'] = '/index.php'; | ||
$_SERVER['SCRIPT_FILENAME'] = __DIR__ . '/web/index.php'; | ||
include __DIR__ . '/web/index.php'; | ||
} |
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,29 @@ | ||
<?php | ||
|
||
use yii\helpers\Html; | ||
|
||
/** @var $this \yii\web\View */ | ||
/** @var $content string */ | ||
|
||
?> | ||
<?php $this->beginPage() ?> | ||
<!DOCTYPE html> | ||
<html lang="<?= Yii::$app->language ?>"> | ||
<head> | ||
<meta charset="<?= Yii::$app->charset ?>"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<?= Html::csrfMetaTags() ?> | ||
<title><?= Html::encode(empty($this->title) ? '' : $this->title . ' - ') ?></title> | ||
<?php $this->head() ?> | ||
</head> | ||
<body> | ||
<?php $this->beginBody() ?> | ||
|
||
<div class="wrap"> | ||
<?= $content ?> | ||
</div> | ||
|
||
<?php $this->endBody() ?> | ||
</body> | ||
</html> | ||
<?php $this->endPage() ?> |
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,10 @@ | ||
<?php | ||
|
||
use yii\helpers\Html; | ||
|
||
/** @var $this \yii\web\View */ | ||
|
||
?> | ||
<h1>API Backend</h1> | ||
|
||
Go to <?= Html::a('/gii', ['/gii']) ?> to generate an API from OpenAPI spec. |
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,6 @@ | ||
RewriteEngine on | ||
# If a directory or a file exists, use the request directly | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
# Otherwise forward the request to index.php | ||
RewriteRule . index.php |
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,2 @@ | ||
* | ||
!.gitignore |
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,8 @@ | ||
<?php | ||
|
||
require(__DIR__ . '/../../config/env.php'); | ||
|
||
$config = require(__DIR__ . '/../config/app-' . YII_ENV . '.php'); | ||
|
||
$app = new yii\web\Application($config); | ||
$app->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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
User-agent: * | ||
Disallow: / |
Oops, something went wrong.