Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation and setting example requirement to 1.*
- Loading branch information
Jordan Hall
committed
Jan 13, 2017
1 parent
66a0bc2
commit 78d90e2
Showing
2 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,44 @@ | ||
# php-dcom | ||
PHP Database Connection Object Manager | ||
# 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 DivineOmega/php-dcom` to install. | ||
|
||
## Usage | ||
|
||
You need to 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_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 | ||
``` | ||
|
||
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. | ||
|
||
```php | ||
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. | ||
|
||
## Example | ||
|
||
For an actual example of how to use PHP DCOM, see the [`test` directory](test/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
|
||
"require": { | ||
"DivineOmega/php-dcom": "dev-master" | ||
"DivineOmega/php-dcom": "1.*" | ||
} | ||
} |