{"id":37006058,"url":"https://github.com/fabiang/doctrine-switch-connection","last_synced_at":"2026-01-14T00:41:46.707Z","repository":{"id":56980983,"uuid":"337995735","full_name":"fabiang/doctrine-switch-connection","owner":"fabiang","description":"Laminas \u0026 Zend Framework module to switch the DB connection depending on a session value","archived":true,"fork":false,"pushed_at":"2021-02-11T11:08:57.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-28T23:47:53.494Z","etag":null,"topics":["doctrine","laminas","laminas-mvc","zend-framework"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabiang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-11T10:25:45.000Z","updated_at":"2023-01-27T23:01:43.000Z","dependencies_parsed_at":"2022-08-21T08:40:52.282Z","dependency_job_id":null,"html_url":"https://github.com/fabiang/doctrine-switch-connection","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fabiang/doctrine-switch-connection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiang%2Fdoctrine-switch-connection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiang%2Fdoctrine-switch-connection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiang%2Fdoctrine-switch-connection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiang%2Fdoctrine-switch-connection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiang","download_url":"https://codeload.github.com/fabiang/doctrine-switch-connection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiang%2Fdoctrine-switch-connection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["doctrine","laminas","laminas-mvc","zend-framework"],"created_at":"2026-01-14T00:41:46.562Z","updated_at":"2026-01-14T00:41:46.683Z","avatar_url":"https://github.com/fabiang.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fabiang/doctrine-switch-connection\n\n[![Build Status](https://travis-ci.com/fabiang/doctrine-switch-connection.svg?branch=master)](https://travis-ci.com/fabiang/doctrine-switch-connection)\n\nThis Laminas and Zend Framework 3 module helps you to switch your Doctrine connection depending on some others object value.\n\n```bash\ncomposer require fabiang/doctrine-switch-connection\n```\n\nAdd the module to your `application.config.php`:\n\n```php\n\u003c?php\n\nreturn [\n    'modules'                 =\u003e [\n        /** more modules */\n        'Fabiang\\Common\\SwitchDatabase',\n    ],\n];\n```\n\nMake sure you have `DoctrineORMModule` loaded before, as this module depends on it.\n\n## Configuration\n\nConfigure your `doctrine.local.php` like the following:\n\n```php\n\u003c?php\n\nuse Doctrine\\DBAL\\Driver\\PDOMySql\\Driver as MySQLDriver;\nuse Fabiang\\Common\\SwitchDatabase\\Doctrine\\ConnectionFactory;\n\nreturn [\n    'doctrine' =\u003e [\n        // configure your database connections\n        'connection' =\u003e [\n            // use orm_default in your app and that factory will then return one of these\n            'orm_conn1' =\u003e [\n                'driverClass' =\u003e MySQLDriver::class,\n                'params'      =\u003e [\n                    'host'     =\u003e getenv('DB_CONN1_HOST'),\n                    'port'     =\u003e getenv('DB_CONN1_PORT'),\n                    'user'     =\u003e getenv('DB_CONN1_USER'),\n                    'password' =\u003e getenv('DB_CONN1_PASSWORD'),\n                    'dbname'   =\u003e getenv('DB_CONN1_DBNAME'),\n                    'charset'  =\u003e 'utf8mb4',\n                ]\n            ],\n            'orm_conn2' =\u003e [\n                'driverClass' =\u003e MySQLDriver::class,\n                'params'      =\u003e [\n                    'host'     =\u003e getenv('DB_CONN2_HOST'),\n                    'port'     =\u003e getenv('DB_CONN2_PORT'),\n                    'user'     =\u003e getenv('DB_CONN2_USER'),\n                    'password' =\u003e getenv('DB_CONN2_PASSWORD'),\n                    'dbname'   =\u003e getenv('DB_CONN2_DBNAME'),\n                    'charset'  =\u003e 'utf8mb4',\n                ]\n            ],\n        ]\n    ],\n    'service_manager' =\u003e [\n        // configure your connection factories\n        'factories'          =\u003e [\n            'doctrine.connection.orm_conn1' =\u003e ConnectionFactory::class,\n            'doctrine.connection.orm_conn2' =\u003e ConnectionFactory::class,\n        ]\n    ],\n    'switch-database' =\u003e [\n        // map value received from object to connection name\n        'connection_mapping' =\u003e [\n            'Fabiang' =\u003e 'orm_conn2',\n            'Test1'   =\u003e 'orm_conn1',\n            'Test2'   =\u003e 'orm_conn1',\n        ],\n        'default_connection' =\u003e 'orm_conn1',\n        // configure the object, from whom to receive the value\n        // the value returned is used by `connection_mapping` to map\n        // the value to the connection name\n        'session_service'    =\u003e [\n            // the service name to receive from container\n            'name' =\u003e 'autentication_storage_session',\n            'key'  =\u003e [\n                'name' =\u003e 'companyBrand', // property or method name\n                'type' =\u003e 'property', // 'property' or 'method'\n            ]\n        ],\n    ],\n];\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiang%2Fdoctrine-switch-connection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiang%2Fdoctrine-switch-connection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiang%2Fdoctrine-switch-connection/lists"}