{"id":15984876,"url":"https://github.com/divineomega/php-dcom","last_synced_at":"2025-04-04T20:46:53.186Z","repository":{"id":56969678,"uuid":"78854587","full_name":"DivineOmega/php-dcom","owner":"DivineOmega","description":"PHP Database Connection Object Manager","archived":false,"fork":false,"pushed_at":"2018-02-14T22:08:12.000Z","size":11,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T20:08:03.812Z","etag":null,"topics":["database-connection","mysqli","pdo","php-library"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DivineOmega.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-13T14:07:16.000Z","updated_at":"2019-05-21T07:37:23.000Z","dependencies_parsed_at":"2022-08-21T10:50:48.314Z","dependency_job_id":null,"html_url":"https://github.com/DivineOmega/php-dcom","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fphp-dcom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fphp-dcom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fphp-dcom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fphp-dcom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DivineOmega","download_url":"https://codeload.github.com/DivineOmega/php-dcom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249618,"owners_count":20908211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-connection","mysqli","pdo","php-library"],"created_at":"2024-10-08T02:10:57.392Z","updated_at":"2025-04-04T20:46:53.154Z","avatar_url":"https://github.com/DivineOmega.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP DCOM\n\nThe PHP DCOM (Database Connection Object Manager) is designed to allow easy management of \nmultiple database connection objects. It stores database connection details within a `.env`\nfile in the root of your project.\n\n## Installation\n\nSimple run `composer require DivineOmega/php-dcom` to install.\n\nYou will need to set environment variables to use this library. If you are not using a\nframework that allows you to set these easily, you can install the `dotenv-loader` \npackage which will immediately allow do so via a `.env` file.\n\nTo install `dotenv-loader`, just run: `composer require DivineOmega/dotenv-loader`.\n\n## Usage\n\nThese usage instructions assume you are able to set environment variables via a `.env`\nfile. If needed, create a `.env` file in the root of your project (alongside your \n`composer.json` file). This will be used to store you database connection details,\nin the following format.\n\n```\nDCOM_MAIN_OBJECT_TYPE=mysqli\nDCOM_MAIN_DATABASE_TYPE=mysql\n\nDCOM_MAIN_DATABASE_HOST=localhost\nDCOM_MAIN_DATABASE_USERNAME=username\nDCOM_MAIN_DATABASE_PASSWORD=password\nDCOM_MAIN_DATABASE_NAME=testdb\n```\n\nDCOM supports the creation of both `mysqli` and `pdo` objects.\n\nAfter setting up your `.env` file, you can then establish a connection to the \ndatabase, as shown below. DCOM will ensure your application only uses a \nsingle connection to each database per request.\n\n```php\nrequire 'vendor/autoload.php';\n\nuse \\DivineOmega\\DCOM\\DCOM;\n\n$mysqli = DCOM::getConnection(\"main\");\n```\n\nNote that the connection name passed to the `getConnection` method matches \nwhat is defined in the `.env` file. You can therefore change this argument in\norder to manage and connect to multiple databases easily.\n\n## Example\n\nFor an actual example of how to use PHP DCOM, see the [`test` directory](test/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivineomega%2Fphp-dcom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivineomega%2Fphp-dcom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivineomega%2Fphp-dcom/lists"}