{"id":16675811,"url":"https://github.com/mpyw/laravel-pdo-emulation-control","last_synced_at":"2025-06-25T23:35:37.287Z","repository":{"id":45690402,"uuid":"234581778","full_name":"mpyw/laravel-pdo-emulation-control","owner":"mpyw","description":"Temporarily enable/disable PDO prepared statement emulation","archived":false,"fork":false,"pushed_at":"2025-03-04T06:44:38.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-20T21:12:53.574Z","etag":null,"topics":["laravel","pdo","php"],"latest_commit_sha":null,"homepage":"","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/mpyw.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-17T15:54:01.000Z","updated_at":"2025-03-04T06:44:41.000Z","dependencies_parsed_at":"2025-04-09T20:36:20.318Z","dependency_job_id":"8beb7b9a-a4f5-4cb1-8d5f-bcb9139e169c","html_url":"https://github.com/mpyw/laravel-pdo-emulation-control","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":0.03448275862068961,"last_synced_commit":"6861190e2e68dccca35ed1e64c1904e2179c5759"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/mpyw/laravel-pdo-emulation-control","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Flaravel-pdo-emulation-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Flaravel-pdo-emulation-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Flaravel-pdo-emulation-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Flaravel-pdo-emulation-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpyw","download_url":"https://codeload.github.com/mpyw/laravel-pdo-emulation-control/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Flaravel-pdo-emulation-control/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261973253,"owners_count":23238540,"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":["laravel","pdo","php"],"created_at":"2024-10-12T13:07:57.173Z","updated_at":"2025-06-25T23:35:37.260Z","avatar_url":"https://github.com/mpyw.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel PDO Emulation Control\u003cbr\u003e[![Build Status](https://github.com/mpyw/laravel-pdo-emulation-control/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mpyw/laravel-pdo-emulation-control/actions) [![Coverage Status](https://coveralls.io/repos/github/mpyw/laravel-pdo-emulation-control/badge.svg?branch=master)](https://coveralls.io/github/mpyw/laravel-pdo-emulation-control?branch=master)\n\nTemporarily enable/disable PDO prepared statement emulation.\n\n## Requirements\n\n| Package | Version                               | Mandatory |\n|:--------|:--------------------------------------|:---------:|\n| PHP     | \u003ccode\u003e^8.2\u003c/code\u003e                     |     ✅     |\n| Laravel | \u003ccode\u003e^11.0 \u0026#124;\u0026#124; ^12.0\u003c/code\u003e |     ✅     |\n| PHPStan | \u003ccode\u003e\u0026gt;=2.0\u003c/code\u003e                 |           |\n\n\u003e [!NOTE]\n\u003e Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.\n\n## Installing\n\n```\ncomposer require mpyw/laravel-pdo-emulation-control\n```\n\n## Basic Usage\n\n\u003e [!IMPORTANT]\n\u003e The default implementation is provided by `ConnectionServiceProvider`, however, **package discovery is not available**.\nBe careful that you MUST register it in **`config/app.php`** by yourself.\n\n```php\n\u003c?php\n\nreturn [\n\n    /* ... */\n\n    'providers' =\u003e [\n        /* ... */\n\n        Mpyw\\LaravelPdoEmulationControl\\ConnectionServiceProvider::class,\n\n        /* ... */\n    ],\n\n];\n```\n\n```php\n\u003c?php\n\nuse Illuminate\\Support\\Facades\\DB;\n\n// Temporarily enable PDO prepared statement emulation.\nDB::emulated(function () {\n    // Your code goes here\n});\n\n// Temporarily disable PDO prepared statement emulation.\n// (Only if you've already configured your connection by options [PDO::ATTR_EMULATE_PREPARES =\u003e true])\nDB::native(function () {\n    // Your code goes here    \n});\n```\n\n\u003e [!IMPORTANT]\n\u003e Note that `DB::getPdo()` `DB::getReadPdo()` are not always called even though these methods directly touch the `PDO` instances.\n\u003e **Connections are lazily resolved as possible as they can.**\n\u003e `PDO::setAttribute()` is called only after the `PDO` instance has been created and the socket connection to the database has been really established.\n\n## Advanced Usage\n\n\u003e [!TIP]\n\u003e You can extend Connection classes with `ControlsEmulation` trait by yourself.\n\n```php\n\u003c?php\n\nnamespace App\\Providers;\n\nuse App\\Database\\MySqlConnection;\nuse Illuminate\\Database\\Connection;\nuse Illuminate\\Support\\ServiceProvider;\n\nclass DatabaseServiceProvider extends ServiceProvider\n{\n    public function register(): void\n    {\n        Connection::resolverFor('mysql', function (...$parameters) {\n            return new MySqlConnection(...$parameters);\n        });\n    }\n}\n```\n\n```php\n\u003c?php\n\nnamespace App\\Database;\n\nuse Illuminate\\Database\\Connection as BaseMySqlConnection;\nuse Mpyw\\LaravelPdoEmulationControl\\ControlsEmulation;\n\nclass MySqlConnection extends BaseMySqlConnection\n{\n    use ControlsEmulation;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpyw%2Flaravel-pdo-emulation-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpyw%2Flaravel-pdo-emulation-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpyw%2Flaravel-pdo-emulation-control/lists"}