Skip to content

Commit 2bbf444

Browse files
committed
Rename YII_ to APP_
1 parent c06b359 commit 2bbf444

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727

2828
env:
2929
key: cache-v1
30-
YII_C3: true
31-
YII_ENV: test
32-
YII_DEBUG: false
30+
APP_C3: true
31+
APP_ENV: test
32+
APP_DEBUG: false
3333

3434
runs-on: ${{ matrix.os }}
3535

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ RUN --mount=type=cache,target=/tmp/cache \
4646
SH
4747

4848
FROM base AS prod
49-
ENV YII_ENV=prod
49+
ENV APP_ENV=prod
5050

5151
COPY --from=prod-builder --chown=www-data:www-data /app /app
5252
USER www-data

docker/compose.dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ services:
99
GID: ${GID}
1010
environment:
1111
XDEBUG_MODE: "${XDEBUG_MODE:-develop}"
12-
YII_ENV: "${YII_ENV:-dev}"
13-
YII_DEBUG: ${YII_DEBUG:-true}
12+
APP_ENV: "${APP_ENV:-dev}"
13+
APP_DEBUG: ${APP_DEBUG:-true}
1414
SERVER_NAME: ":80"
1515
restart: unless-stopped
1616
ports:

docker/compose.prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ services:
99
- caddy_config:/config
1010
environment:
1111
SERVER_NAME: ":80"
12-
YII_ENV: "${YII_ENV:-prod}"
13-
YII_DEBUG: ${YII_DEBUG:-false}
12+
APP_ENV: "${APP_ENV:-prod}"
13+
APP_DEBUG: ${APP_DEBUG:-false}
1414
deploy:
1515
replicas: 2
1616
update_config:

docker/compose.test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ services:
99
GID: ${GID}
1010
environment:
1111
XDEBUG_MODE: "off"
12-
YII_ENV: "test"
13-
YII_DEBUG: "false"
12+
APP_ENV: "test"
13+
APP_DEBUG: "false"
1414
SERVER_NAME: ":80"
1515
volumes:
1616
- ../:/app

public/index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require_once dirname(__DIR__) . '/vendor/autoload.php';
99
Environment::prepare();
1010

11-
if (Environment::yiiC3()) {
11+
if (Environment::appC3()) {
1212
$c3 = dirname(__DIR__) . '/c3.php';
1313
if (file_exists($c3)) {
1414
require_once $c3;
@@ -34,8 +34,8 @@
3434
// Run HTTP application runner
3535
$runner = new HttpApplicationRunner(
3636
rootPath: dirname(__DIR__),
37-
debug: Environment::yiiDebug(),
38-
checkEvents: Environment::yiiDebug(),
39-
environment: Environment::yiiEnv(),
37+
debug: Environment::appDebug(),
38+
checkEvents: Environment::appDebug(),
39+
environment: Environment::appEnv(),
4040
);
4141
$runner->run();

src/Environment.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,55 +20,55 @@ final class Environment
2020
public static function prepare(): void
2121
{
2222
self::setEnvironment();
23-
self::setBoolean('YII_C3', false);
24-
self::setBoolean('YII_DEBUG', false);
23+
self::setBoolean('APP_C3', false);
24+
self::setBoolean('APP_DEBUG', false);
2525
}
2626

2727
/**
2828
* @return non-empty-string
2929
*/
30-
public static function yiiEnv(): string
30+
public static function appEnv(): string
3131
{
3232
/** @var non-empty-string */
33-
return self::$values['YII_ENV'];
33+
return self::$values['APP_ENV'];
3434
}
3535

3636
public static function isDev(): bool
3737
{
38-
return self::yiiEnv() === self::DEV;
38+
return self::appEnv() === self::DEV;
3939
}
4040

4141
public static function isTest(): bool
4242
{
43-
return self::yiiEnv() === self::TEST;
43+
return self::appEnv() === self::TEST;
4444
}
4545

4646
public static function isProd(): bool
4747
{
48-
return self::yiiEnv() === self::PROD;
48+
return self::appEnv() === self::PROD;
4949
}
5050

51-
public static function yiiC3(): bool
51+
public static function appC3(): bool
5252
{
5353
/** @var bool */
54-
return self::$values['YII_C3'];
54+
return self::$values['APP_C3'];
5555
}
5656

57-
public static function yiiDebug(): bool
57+
public static function appDebug(): bool
5858
{
5959
/** @var bool */
60-
return self::$values['YII_DEBUG'];
60+
return self::$values['APP_DEBUG'];
6161
}
6262

6363
private static function setEnvironment(): void
6464
{
65-
$environment = self::getRawValue('YII_ENV');
65+
$environment = self::getRawValue('APP_ENV');
6666
if (!in_array($environment, [self::DEV, self::TEST, self::PROD], true)) {
6767
throw new RuntimeException(
6868
sprintf('"%s" is invalid environment.', $environment ?? '')
6969
);
7070
}
71-
self::$values['YII_ENV'] = $environment;
71+
self::$values['APP_ENV'] = $environment;
7272
}
7373

7474
private static function setBoolean(string $key, bool $default): void

tests/Support/FunctionalTester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function sendRequest(ServerRequestInterface $request): ResponseInterface
3838
{
3939
$runner = new HttpApplicationRunner(
4040
rootPath: dirname(__DIR__, 2),
41-
environment: Environment::yiiEnv(),
41+
environment: Environment::appEnv(),
4242
);
4343

4444
$response = $runner->runAndGetResponse($request);

yii

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Environment::prepare();
1313
// Run console application runner
1414
$runner = new ConsoleApplicationRunner(
1515
rootPath: __DIR__,
16-
debug: Environment::yiiDebug(),
17-
checkEvents: Environment::yiiDebug(),
18-
environment: Environment::yiiEnv(),
16+
debug: Environment::appDebug(),
17+
checkEvents: Environment::appDebug(),
18+
environment: Environment::appEnv(),
1919
);
2020
$runner->run();

0 commit comments

Comments
 (0)