{"id":15524214,"url":"https://github.com/leocavalcante/swoole-postgresql-doctrine-driver","last_synced_at":"2025-04-23T07:30:18.946Z","repository":{"id":44640208,"uuid":"350488491","full_name":"leocavalcante/swoole-postgresql-doctrine-driver","owner":"leocavalcante","description":"🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL client","archived":false,"fork":false,"pushed_at":"2022-02-02T20:51:04.000Z","size":71,"stargazers_count":25,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T22:41:18.864Z","etag":null,"topics":["async","connection-pool","coroutine","database","dbal","doctrine","driver","orm","pool","postgresql","swoole"],"latest_commit_sha":null,"homepage":"https://wiki.swoole.com/#/coroutine_client/postgresql","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leocavalcante.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":"2021-03-22T21:02:03.000Z","updated_at":"2025-02-03T14:55:15.000Z","dependencies_parsed_at":"2022-09-12T15:32:42.111Z","dependency_job_id":null,"html_url":"https://github.com/leocavalcante/swoole-postgresql-doctrine-driver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocavalcante%2Fswoole-postgresql-doctrine-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocavalcante%2Fswoole-postgresql-doctrine-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocavalcante%2Fswoole-postgresql-doctrine-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocavalcante%2Fswoole-postgresql-doctrine-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leocavalcante","download_url":"https://codeload.github.com/leocavalcante/swoole-postgresql-doctrine-driver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250390740,"owners_count":21422768,"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":["async","connection-pool","coroutine","database","dbal","doctrine","driver","orm","pool","postgresql","swoole"],"created_at":"2024-10-02T10:49:49.255Z","updated_at":"2025-04-23T07:30:18.924Z","avatar_url":"https://github.com/leocavalcante.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swoole Coroutine PostgreSQL Doctrine DBAL Driver\n\nA `Doctrine\\DBAL\\Driver` implementation on top of `Swoole\\Coroutine\\PostgreSQL`.\n\n## Getting started\n\n### Install\n\n```shell\ncomposer require leocavalcante/swoole-postgresql-doctrine-driver\n```\n\n### Usage\n\nDoctrine parameters, for both DBAL and ORM projects, accepts the `driverClass` option; it is where we can inject this project's driver:\n\n```php\nuse Doctrine\\DBAL\\{Driver, DriverManager};\n\n$params = [\n    'dbname' =\u003e 'postgres',\n    'user' =\u003e 'postgres',\n    'password' =\u003e 'postgres',\n    'host' =\u003e 'db',\n    'driverClass' =\u003e Driver\\Swoole\\Coroutine\\PostgreSQL\\Driver::class,\n    'poolSize' =\u003e 8,\n];\n\n$conn = DriverManager::getConnection($params);\n```\n\n*Yes, I deliberately used the `Doctrine\\DBAL\\Driver` namespace + `Swoole\\Coroutine\\PostgreSQL` namespace, so it is not confusing.*\n\n#### You are ready to rock inside Coroutines (Fibers):\n\n```php\nCo\\run(static function() use ($conn): void {\n    $results = [];\n    $wg = new Co\\WaitGroup();\n    $start_time = time();\n\n    Co::create(static function() use (\u0026$results, $wg, $conn): void {\n        $wg-\u003eadd();\n        $results[] = $conn-\u003eexecuteQuery('select 1, pg_sleep(1)')-\u003efetchOne();\n        $wg-\u003edone();\n    });\n\n    Co::create(static function() use (\u0026$results, $wg, $conn): void {\n        $wg-\u003eadd();\n        $results[] = $conn-\u003eexecuteQuery('select 1, pg_sleep(1)')-\u003efetchOne();\n        $wg-\u003edone();\n    });\n\n    $wg-\u003ewait();\n    $elapsed = time() - $start_time;\n    $sum = array_sum($results);\n\n    echo \"Two pg_sleep(1) queries in $elapsed second, returning: $sum\\n\";\n});\n```\n\nYou should be seeing `Two pg_sleep(1) queries in 1 second, returning: 2` and the total time should **not** be 2 (the sum of `pg_sleep(1)`'s) because they ran concurrently.\n\n```shell\nreal    0m1.228s\nuser    0m0.036s\nsys     0m0.027s\n```\n\n## Developing\n\n### Use Composer through Docker\n\n```shell\ndocker-compose run --rm composer install\ndocker-compose run --rm composer test\n```\n\nIt will build a development image with PHP, Swoole, Swoole's PostgreSQL extension and PCOV for coverage.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleocavalcante%2Fswoole-postgresql-doctrine-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleocavalcante%2Fswoole-postgresql-doctrine-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleocavalcante%2Fswoole-postgresql-doctrine-driver/lists"}