Skip to content

Commit

Permalink
Dotenv の設定箇所を元に戻した
Browse files Browse the repository at this point in the history
/config/bootstrap.php でないと正常動作しない
  • Loading branch information
ryuring committed Aug 4, 2024
1 parent f7b9cb8 commit b8a3307
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 31 deletions.
14 changes: 7 additions & 7 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@
* security risks. See https://github.com/josegonzalez/php-dotenv#general-security-information
* for more information for recommended practices.
*/
//if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
// $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
// $dotenv->parse()
// ->putenv()
// ->toEnv()
// ->toServer();
//}
if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
$dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
$dotenv->parse()
->putenv()
->toEnv()
->toServer();
}

/*
* Read configuration file and inject configuration into various
Expand Down
13 changes: 0 additions & 13 deletions plugins/baser-core/src/BaserCorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,6 @@ class BaserCorePlugin extends BcPlugin implements AuthenticationServiceProviderI
*/
public function bootstrap(PluginApplicationInterface $app): void
{
/**
* Dotenv が読み込まれていない場合は読み込む
*/
if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
$dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
$dotenv->parse()
->putenv()
->toEnv()
->toServer();
}

/**
* composer インストール対応
* composer でインストールした場合、プラグインは vendor 保存されるためパスを追加
Expand Down Expand Up @@ -161,8 +150,6 @@ public function bootstrap(PluginApplicationInterface $app): void
Log::setConfig(Configure::consume('Log'));
}



/**
* プラグインロード
*/
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/src/Command/ComposerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser):
'required' => true
]);
$parser->addOption('php', [
'help' => __d('baser_core', 'データベース接続名'),
'help' => __d('baser_core', 'PHPのパス'),
'default' => 'php'
]);
$parser->addOption('dir', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function setUp(): void
public function testBuildOptionParser()
{
$this->exec('composer --help');
$this->assertOutputContains('データベース接続名');
$this->assertOutputContains('PHPのパス');
$this->assertOutputContains('実行対象ディレクトリ');
$this->assertOutputContains('アップデート対象のバージョン番号');
}
Expand Down
9 changes: 0 additions & 9 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@
Configure::write('App.fullBaseUrl', 'http://localhost');
}

// Dotenv 読み込み 2024/08/04 ryuring
if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
$dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
$dotenv->parse()
->putenv()
->toEnv()
->toServer();
}

// エラー設定 2023/01/12 ryuring
// CakePHP4.4 で PaginatorComponent が非推奨となり、deprecated エラーが発生するため
// 強制的に errorLevel を書き換えて再設定を実行
Expand Down

0 comments on commit b8a3307

Please sign in to comment.