Skip to content
developed by

Installation

Installation method will depend on which flavor you want to use:

Laravel (experimental)

DbToolsBundle follows Symfony Best Practices for Bundles, you should not be lost if you are a regular Symfony developer.

Requirements & Dependencies

  • PHP 8.1 or higher
  • PHP 8.1 or higher
  • Symfony 6.0 or higher
  • Doctrine/DBAL, DbToolsBundle takes advantage of available DBAL connections

Currently supported database vendors:

  • PostgreSQL 10 and above
    (previous versions from 9.5 are untested but should work)
  • MariaDB 10.11 and above
  • MySQL 5.7, 8.0 and above
  • SQLite 3.0 and above

INFO

The library could also work with other database vendors. Check out the supported database vendors page.

Installation

Add DbToolsBundle to your PHP project with composer:

sh
composer require makinacorpus/db-tools-bundle

Then, copy the default configuration file from the vendor directory:

sh
cd your_project_dir
cp vendor/makinacorpus/db-tools-bundle/config/db_tools.standalone.sample.yaml db_tools.config.yaml

Update this file to your needs. The only required parameter is connections in which you must provided an URL connection string.

Add DbToolsBundle to your Symfony project with composer:

sh
composer require makinacorpus/db-tools-bundle

Then, activate the bundle:

php
// config/bundles.php

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    //...
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
    // ...
    MakinaCorpus\DbToolsBundle\Bridge\Symfony\DbToolsBundle::class => ['all' => true], 
];

Finally, copy the default configuration file from the vendor directory:

sh
cd your_project_dir
cp vendor/makinacorpus/db-tools-bundle/config/packages/db_tools.yaml config/packages/

Feel free to read this configuration file, it will learn you basics about this bundle.

You can add the DbToolsBundle image to your docker compose stack like in this example:

yaml
version: '3.8'

services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_PASSWORD: password
      POSTGRES_DB: db
      POSTGRES_USER: db
    ports:
      - 5439:5432
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - site

  dbtools: 
    image: makinacorpus/dbtoolsbundle:stable
    networks: 
      - site
    volumes: 
      - ./db_tools.config.yaml:/var/www/db_tools.config.yaml
      - ./db_tools:/var/www/var/db_tools

networks:
  site:

volumes:
  pgdata:

Then, copy the default configuration file from the DbToolsBundle container:

sh
cd your_project_dir

docker compose cp dbtoolsbundle:/var/www/vendor/makinacorpus/db-tools-bundle/config/db_tools.standalone.sample.yaml db_tools.config.yaml

Update this file to your needs. The only required parameter is connections in which you must provided a connection string.

In our example, the connection string will be pgsql://db:password@postgres:5432/db?version=15.0.

That's it, DbToolsBundle is now ready to be used.

But before starting to use it, check if it succeeds to find back up and restoration binaries for your database connection(s):

sh
vendor/bin/db-tools check
sh
php bin/console db-tools:check
sh
docker compose run dbtools check

TIP

If this command returns some errors, go to the binaries configuration section to understand how to solve them.

WARNING

While installing the bundle through composer, the standalone binary will also be installed in the vendor/bin/ directory.

You must not use this binary but the Symfony Console commands.

The binary will try to look for a config in db_tools.config.yaml while the Symfony Console commands will use the bundle configuration (which autoconfigures the database connections).

Released under the MIT License.