2017 © Pedro Peláez
 

library php-dcom

PHP Database Connection Object Manager

image

divineomega/php-dcom

PHP Database Connection Object Manager

  • Wednesday, February 14, 2018
  • by DivineOmega
  • Repository
  • 1 Watchers
  • 1 Stars
  • 71 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 7 Versions
  • 22 % Grown

The README.md

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., (*1)

Installation

Simple run composer require DivineOmega/php-dcom to install., (*2)

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., (*3)

To install dotenv-loader, just run: composer require DivineOmega/dotenv-loader., (*4)

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., (*5)

DCOM_MAIN_OBJECT_TYPE=mysqli
DCOM_MAIN_DATABASE_TYPE=mysql

DCOM_MAIN_DATABASE_HOST=localhost
DCOM_MAIN_DATABASE_USERNAME=username
DCOM_MAIN_DATABASE_PASSWORD=password
DCOM_MAIN_DATABASE_NAME=testdb

DCOM supports the creation of both mysqli and pdo objects., (*6)

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., (*7)

require 'vendor/autoload.php';

use \DivineOmega\DCOM\DCOM;

$mysqli = DCOM::getConnection("main");

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., (*8)

Example

For an actual example of how to use PHP DCOM, see the test directory., (*9)

The Versions

14/02 2018

dev-master

9999999-dev https://github.com/DivineOmega/php-dcom

PHP Database Connection Object Manager

  Sources   Download

LGPL3 LGPL-3.0-only

The Requires

  • php >=5.5.9

 

database php pdo mysqli php library database connections database connection php library

14/02 2018

v1.2.2

1.2.2.0 https://github.com/DivineOmega/php-dcom

PHP Database Connection Object Manager

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.5.9

 

database php pdo mysqli php library database connections database connection php library

05/05 2017

v1.2.1

1.2.1.0 https://github.com/DivineOmega/php-dcom

PHP Database Connection Object Manager

  Sources   Download

LGPL3

The Requires

  • php >=5.5.9

 

database php pdo mysqli php library database connections database connection php library

16/01 2017

v1.2.0

1.2.0.0 https://github.com/DivineOmega/php-dcom

PHP Database Connection Object Manager

  Sources   Download

LGPL3

The Requires

  • php >=5.5.9

 

database php pdo mysqli php library database connections database connection php library

16/01 2017

v1.1.1

1.1.1.0 https://github.com/DivineOmega/php-dcom

PHP Database Connection Object Manager

  Sources   Download

LGPL3

The Requires

 

database php pdo mysqli php library database connections database connection php library

16/01 2017

v1.1.0

1.1.0.0 https://github.com/DivineOmega/php-dcom

PHP Database Connection Object Manager

  Sources   Download

LGPL3

The Requires

 

database php pdo mysqli php library database connections database connection php library

13/01 2017

v1.0.0

1.0.0.0 https://github.com/DivineOmega/php-dcom

PHP Database Connection Object Manager

  Sources   Download

LGPL3

The Requires

 

database php pdo mysqli php library database connections database connection php library