Download the PHP package feroz/dynamic-db-bundle without Composer

On this page you can find all versions of the php package feroz/dynamic-db-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dynamic-db-bundle

DynamicDbBundle

DynamicDbBundle is a Symfony bundle that allows you to store database connection configurations in a database table and seamlessly fetch and instantiate connections and entity managers at runtime.

With this bundle, you can natively use $doctrine->getConnection('dynamic_name') or $doctrine->getManager('dynamic_name') just like any conventionally configured connection in your doctrine.yaml.


Features


Installation

Add the bundle to your project via Composer (if published):

Ensure the bundle is registered in your config/bundles.php:


Usage Guide

1. Create a Configuration Entity

Create a standard Doctrine Entity in your application that stores the database connection configurations. Crucially, this entity must implement DynamicDbConnectionInterface and provide implementations for all interface methods, including setSecret().

The setSecret() method is called automatically by DynamicDbProvider before building the connection config, allowing your entity to make the secret available to downstream logic (e.g., for custom password decryption).

2. Fetch the Dynamic Connection

You can fetch the connection or the manager directly through Symfony's core Doctrine integration! The bundle decorates the Doctrine registry to seamlessly integrate.

3. Password Encryption (Consumer Responsibility)

The bundle does not provide a built-in encryption utility. Password encryption and decryption are entirely the consumer's responsibility.

The recommended pattern is:

  1. Encrypt the password before persisting the entity (using any encryption library of your choice).
  2. Decrypt the password inside getDatabasePassword() of your entity, using the secret injected via setSecret().

4. Passing a Secret via Dependency Injection (for Encrypted Passwords)

DynamicDbProvider accepts $secret as an optional constructor parameter. The recommended approach is to bind it in your application's services.yaml using a Symfony parameter (e.g. from an environment variable):

With this configuration, DynamicDbProvider will automatically call $entity->setSecret($secret) on the fetched connection entity before building the connection config, giving the entity access to the secret for custom decryption logic.

If no secret is needed, simply omit the binding — the $secret parameter defaults to null and setSecret() will not be called.


How it Works

  1. When you call $doctrine->getConnection('X') or $doctrine->getManager('X'), the wrapped DynamicRegistryDecorator intercepts the request.
  2. If Doctrine natively doesn't know about connection X, DynamicDbProvider kicks in.
  3. It finds the class implementing DynamicDbConnectionInterface dynamically and uses the default EntityManager to fetch the entity matching connectionName = 'X'.
  4. If a $secret was configured (via DI), it calls $entity->setSecret($secret) on the fetched entity.
  5. The DynamicEntityManagerFactory boots up the new ORM connection using the database connection parameters (or parses a DSN URL using Doctrine's DsnParser).
  6. The new dynamic EntityManager is instantiated by inheriting the exact configuration (metadata mappings, naming strategies, proxies, etc.) of the default EntityManager.
  7. Standard methods like $doctrine->getConnections() or $doctrine->getManagers() are decorated to dynamically include the newly instantiated connections/managers alongside the statically defined ones.
  8. The connection is cached locally for the remainder of the request.

All versions of dynamic-db-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
doctrine/orm Version ^2.2||^3.3
symfony/framework-bundle Version ^5.4 || ^6.0 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package feroz/dynamic-db-bundle contains the following files

Loading the files please wait ...