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

Idea: Get db credentials from project config #44

Closed
barryvdh opened this issue Jan 12, 2016 · 4 comments
Closed

Idea: Get db credentials from project config #44

barryvdh opened this issue Jan 12, 2016 · 4 comments
Assignees
Milestone

Comments

@barryvdh
Copy link

@barryvdh barryvdh commented Jan 12, 2016

It isn't recommended to put database credentials the git repository, so perhaps we should keep them out of the backup config also? And also, a lot of projects already have defined them anyways somewhere.

An option would be to provide some default project parsers, to load the configuration from the actual project.

Laravel -> Load database.php config file, or from .env directly.
Magento -> Parse local.xml file
Drupal -> Parse sites config file

Etc

@sebastianfeldmann
Copy link
Owner

@sebastianfeldmann sebastianfeldmann commented Jan 12, 2016

Great idea.
Let's think of a good way to configure and implement this.

maybe something like

<credentials>
  <provider name="laravel-config" type="Laravel">
    <option name="path" value="path/to/laravel/config"/>
  </provider>
</credentials>

<backup>
   ...
   <source type="mysql" name="CoreDBBackup">
     <option name="credentials.provider" value="laravel-config" />
     <option name="credentials.toUse" valu="mysql" />
   </source>
  ...
</backup>

And inside the Mysql Source class.

if ($this->useCredentialProvider()) {
    $credentials = $this->getCredentials($options);
    $username = $credentials->username;
    $password = $credentials->password;
}

@sebastianfeldmann sebastianfeldmann added this to the Version 3.1.0 milestone Jan 18, 2016
@sebastianfeldmann sebastianfeldmann removed this from the Version 3.1.0 milestone Feb 21, 2016
@sebastianfeldmann sebastianfeldmann self-assigned this Nov 15, 2016
@sebastianfeldmann sebastianfeldmann added this to the Version 3.2.0 milestone Nov 15, 2016
@sebastianfeldmann sebastianfeldmann added this to the Version 4.0.0 milestone Nov 16, 2016
@sebastianfeldmann sebastianfeldmann removed this from the Version 3.2.0 milestone Nov 16, 2016
@sebastianfeldmann
Copy link
Owner

@sebastianfeldmann sebastianfeldmann commented Nov 16, 2016

Had to bump the major version for this but I think it was worth it.

<adapters>
  <adapter name="environment" type="dotenv">
    <option name="file" value=".env" />
  </adapter>
</adapters>

...
  <backup>
   ...
     <source type="mysql" name="CoreDBBackup">
       <option name="user" valu="adapter:environment:DB_USER" />
       <option name="password" value="adapter:environment:DB_PASSWORD" />
     </source>
     ...
  </backup>
...

I'll release version 4.0 as soon as possible.

@sebastianfeldmann
Copy link
Owner

@sebastianfeldmann sebastianfeldmann commented Nov 16, 2016

I decided to use adapters to manipulate the configuration values
before creating the actual configuration. So the application does
not have to know anything about configuration adapters.

But to actually create adapters while handling the configuration,
I had to change the configuration loader interface in a backwards
incompatible way. So I had to increase the major version.

@planetahuevo
Copy link
Sponsor Contributor

@planetahuevo planetahuevo commented Oct 5, 2018

2 questions:

  • Does this mean that we need to update our phpbu.xml files if we upgrade the version?
  • Can we use this variables inside the "path value"?
    I mean:

<option name="path" value="/something/something/adapter:environment:VARIABLE/something"/>
How can make this work?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants