Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder::rebuild() create bad config #23

Closed
loveorigami opened this issue Feb 19, 2019 · 5 comments
Closed

Builder::rebuild() create bad config #23

loveorigami opened this issue Feb 19, 2019 · 5 comments

Comments

@loveorigami
Copy link
Contributor

loveorigami commented Feb 19, 2019

I am create action for rebuild config from cli

namespace console\controllers;

use hiqdev\composer\config\Builder;
use yii\console\Controller;

class ConfigController extends Controller
{
   /**
    * Rebuild config
    */
   public function actionDu(): void
   {
       Builder::rebuild();
       $this->stdout('> ok !' . PHP_EOL);
   }
}

Next run command yii config/du and my appliacation is not worked.
I am run command composer du - all works fine.

Next I compare two configs (cli and composer). They have many differences.

Some of them

01

02

03

and more...

@loveorigami
Copy link
Contributor Author

My config

04

I think - not loaded params from env file.

@loveorigami
Copy link
Contributor Author

Next problems with $ENV['DB_DSN'] and getenv('DB_DSN')

05

6

@loveorigami
Copy link
Contributor Author

I think, it will be fixed, if will do #11

@Spell6inder
Copy link

I also have problems with Builder::rebuild()
For example in my file

// ...
require_once hiqdev\composer\config\Builder::path('defines');
if (YII_ENV_DEV) {
    // my trick
    $_ENV = array_diff_assoc($_ENV, (array) require \hiqdev\composer\config\Builder::path('dotenv'));
    //
    hiqdev\composer\config\Builder::rebuild();
}
// ...

On EnvReader::readRaw($path) we have return array_diff_assoc($newenvs, $oldenvs) but $oldenvs ($_ENV) already populated. As result empty array returned.
In addition, I think my trick can help the author until the problem is fixed.

@loveorigami
Copy link
Contributor Author

After update to last version my problem is not fixed, but have correct $_ENV

2019-10-14_13-04-46

xepozz added a commit to xepozz/hiqdev-fork-composer-config-plugin that referenced this issue Apr 18, 2020
* Add `yiisoft/arrays` to dev requirements

* Move `yiisoft/arrays` from require-dev to require dependencies
@hiqsol hiqsol closed this as completed Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants