Download the PHP package jord-jd/php-dcom without Composer
On this page you can find all versions of the php package jord-jd/php-dcom. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jord-jd/php-dcom
More information about jord-jd/php-dcom
Files in jord-jd/php-dcom
Package php-dcom
Short Description PHP Database Connection Object Manager
License LGPL-3.0-only
Homepage https://github.com/Jord-JD/php-dcom
Informations about the package php-dcom
PHP DCOM
The PHP DCOM (Database Connection Object Manager) is designed to allow easy management of
multiple database connection objects. It stores database connection details within a .env
file in the root of your project.
Installation
Simple run composer require jord-jd/php-dcom to install.
You will need to set environment variables to use this library. If you are not using a
framework that allows you to set these easily, you can install the dotenv-loader
package which will immediately allow do so via a .env file.
To install dotenv-loader, just run: composer require jord-jd/dotenv-loader.
Usage
These usage instructions assume you are able to set environment variables via a .env
file. If needed, create a .env file in the root of your project (alongside your
composer.json file). This will be used to store you database connection details,
in the following format.
DCOM supports the creation of both mysqli and pdo objects.
After setting up your .env file, you can then establish a connection to the
database, as shown below. DCOM will ensure your application only uses a
single connection to each database per request.
Note that the connection name passed to the getConnection method matches
what is defined in the .env file. You can therefore change this argument in
order to manage and connect to multiple databases easily.
Example
For an actual example of how to use PHP DCOM, see the test directory.