From 5fb0f11bba893ef5d5df4404ad0c6132a9eb3258 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula <42547589+terabytesoftw@users.noreply.github.com> Date: Sat, 21 Oct 2023 20:00:30 -0300 Subject: [PATCH] Remove hard code dependency in config. (#9) --- README.md | 13 +++++++++++++ composer.json | 4 +--- config/{web/gii.php => modules.php} | 2 +- config/params.php | 9 --------- 4 files changed, 15 insertions(+), 13 deletions(-) rename config/{web/gii.php => modules.php} (94%) delete mode 100644 config/params.php diff --git a/README.md b/README.md index 6a54382..e713c78 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,19 @@ yii help gii/model yii gii/model --tableName=city --modelClass=City ``` +### Configure with yiisoft/config + +> Add the following code to your `config/config-plugin` file in your application. + +```php +'config-plugin' => [ + 'web' => [ + '$yii2-gii', // add this line + 'web/*.php' + ], +], +``` + ## Testing [Check the documentation testing](/docs/testing.md) to learn about testing. diff --git a/composer.json b/composer.json index 2329dcd..d8ddc34 100644 --- a/composer.json +++ b/composer.json @@ -39,8 +39,7 @@ "source-directory": "config" }, "config-plugin": { - "web": "web/*.php", - "params": "params.php" + "yii2-gii": "modules.php" } }, "config": { @@ -52,7 +51,6 @@ }, "scripts": { "check-dependencies": "composer-require-checker", - "mutation": "roave-infection-static-analysis-plugin", "psalm": "psalm", "test": "phpunit" }, diff --git a/config/web/gii.php b/config/modules.php similarity index 94% rename from config/web/gii.php rename to config/modules.php index e70ed93..329e487 100644 --- a/config/web/gii.php +++ b/config/modules.php @@ -13,7 +13,7 @@ 'modules' => [ 'gii' => [ 'class' => \yii\gii\Module::class, - 'allowedIPs' => $params['yii.gii.allowedIPs'] ?? [], + 'allowedIPs' => $params['yii.gii.allowedIPs'] ?? ['127.0.0.1', '::1'], ], ], ]; diff --git a/config/params.php b/config/params.php deleted file mode 100644 index eee96c6..0000000 --- a/config/params.php +++ /dev/null @@ -1,9 +0,0 @@ - false, // enable gii mode - 'yii.gii.allowedIPs' => ['127.0.0.1', '::1'], // allow gii on localhost only -];