Skip to content

Commit

Permalink
no issue - standalone console tool
Browse files Browse the repository at this point in the history
  • Loading branch information
pounard committed May 24, 2024
1 parent f8ebe33 commit 6de5c83
Show file tree
Hide file tree
Showing 15 changed files with 1,127 additions and 48 deletions.
8 changes: 8 additions & 0 deletions bin/db-tools
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

namespace MakinaCorpus\DbToolsBundle;

require __DIR__ . '/db-tools.php';
34 changes: 34 additions & 0 deletions bin/db-tools.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace MakinaCorpus\DbToolsBundle;

use MakinaCorpus\DbToolsBundle\Helper\Cli\Bootstrap;

(static function (): void {
$autoloadFiles = [
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../../autoload.php',
];

$autoloaderFound = false;
foreach ($autoloadFiles as $autoloadFile) {
if (!\file_exists($autoloadFile)) {
continue;
}
require_once $autoloadFile;
$autoloaderFound = true;
}

if (!$autoloaderFound) {
if (\extension_loaded('phar') && \Phar::running() !== '') {
\fwrite(STDERR, 'The PHAR was built without dependencies!' . \PHP_EOL);
exit(1);
}
\fwrite(STDERR, 'vendor/autoload.php could not be found. Did you run `composer install`?' . \PHP_EOL);
exit(1);
}

Bootstrap::run();
})();
2 changes: 1 addition & 1 deletion config/anonymizations.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ user:
anonymizer: email
options: {domain: 'toto.com'}
# Or not
email: email
#email: email
level:
anonymizer: string
options: {sample: ['none', 'bad', 'good', 'expert']}
Expand Down
63 changes: 63 additions & 0 deletions config/db_tools.standalone.sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This configuration file is an example for standalone usage.
#
# The given parameters you will find in this file must not be set in a Symfony
# application context, and will ignored if so.
#
# All other configuration you can find in the ./packages/db_tools.yaml file
# can be added in this file, you must simply omit the 'db_tools:' top level
# node.

# Working directory is the path to which all relative file references will
# be relative to. If none set, the path will be this file directory instead.
workdir: /var/www/my_project/

# Database connections.
# One line per connection, a single database URL, all options as query
# parameters. Connections will be made using makincorpus/query-builder
# which will raise exceptions when invalid options are found.
# There is less configuration amplitude than using doctrine/dbal in
# Symfony, yet it should be enough in most case.
# In case any options or specific behaviour is missing, please file
# an issue at https://github.com/makinacorpus/php-query-builder/issues
connections:
connection_one: "pgsql://username:password@hostname:port?version=16.0&other_option=..."
connection_two: "mysql://username:password@hostname:port?version=8.1&other_option=..."

# You can explicitely set which will be default connection in use when
# none providen in the command line options. If you omit this configuration
# vlaue, then the first one in the list will be used.
default_connection: connection_one

# Storage is autoconfigured when using Symfony, but when using this
# application standalone, it's on your own. You must provide at least
# a root directory for backups.
storage:
# Path can be relative, it will be relative to the configuration file.
# If none provided, the default will be the following one.
root_dir: ./var/db_tools

# From here, all options in the 'db_tools' section of Symfony configuration
# can be added, including anonymization files configuration.

anonymization:
# From here you can proceed with manual file inclusion. Pathes can be
# either relative or absolute. Relative paths are relative to and resolved
# from this configuration file.
yaml:
connection_one: ./db_tools.anonymizer.connection_one.yaml
# ... other connections ...

# Extra configuration options, if you don't want to split the anonymization
# configuration into multiple files, you can directly write it here. If you
# use the entity dump capability, you can copy paste the result directly
# here.
tables:
connection_one:
# From here, please refer to 'anonymizations.sample.yaml' for sample
# and documentation.
table_name:
column_name:
anonymizer: anonymizer_name
# ... other options...
connection_two:
# ...
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default defineConfig({
{ text: 'Backup & Restore', link: '/backup_restore' },
{ text: 'Statistics', link: '/stats' },
{ text: 'Bundle configuration', link: '/configuration' },
{ text: 'Configuration reference', link: '/configuration/reference' },
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions docs/content/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ all will take place in the `config/packages/db_tools.yaml` file.
A complete example of this file can be found in the bundle sources in: `vendor/makinacorpus/db-tools-bundle/config/packages/db_tools.yaml`
:::

For detailed information about configuration options, please see the
[configuration reference](../configuration/reference).

## Backup configuration

Some options are available to customize how the `db-tools:backup` command works.
Expand Down
Loading

0 comments on commit 6de5c83

Please sign in to comment.