0

I am using the DoctrineORMModule along with my ZendFramework/Laminas Application. So far everything works fine but I'd like to limit the user rights for the db-user in my MySQL database and use the root-user for my doctrine-migrations only. What's the correct way to accomplish this without duplicating the configuration from my App into a separate cli-config? Is there a way to do this?

Checking all documentation and examples didn't help me so far because in all examples a user with full privileges is used for everything. Also I'd like to be able to run the orm:ensure-production-settings command for my production build to ensure that production settings are correct. But this conflicts with the need of different settings for running migrations (upon startup).

Hope someone can help out.

Thank you.

sfass
  • 3
  • 1

1 Answers1

1

I would recommend to have different configs for CLI and for WEB modes.

You can quickly achieve it by having antother configuration file in your config/ directory collection named eg. cli.config.php and beginning with this content:

<?php
declare(strict_types=1);

use App\Application\Handler\Cli;

return PHP_SAPI !== 'cli' ? [] : [
    // your CLI only config.
];

If this file is included after a standard config file, you can override doctrine configuration in here strictly for CLI mode.

yergo
  • 4,761
  • 2
  • 19
  • 41