{"id":13699861,"url":"https://github.com/opencodeco/hyperf-doctrine","last_synced_at":"2026-01-14T12:17:54.497Z","repository":{"id":193047673,"uuid":"688000941","full_name":"opencodeco/hyperf-doctrine","owner":"opencodeco","description":"🎲 This project provides an integration for the Doctrine ORM and the Hyperf framework.","archived":false,"fork":true,"pushed_at":"2023-09-06T18:14:45.000Z","size":34,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-09T13:40:03.157Z","etag":null,"topics":["connection-pool","database","doctrine","hacktoberfest","hyperf","orm"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"leocavalcante/hyperf-doctrine","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opencodeco.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}},"created_at":"2023-09-06T12:53:15.000Z","updated_at":"2024-12-04T00:53:56.000Z","dependencies_parsed_at":"2023-09-06T14:44:01.988Z","dependency_job_id":"29ec41ed-ceb3-429b-8d3d-5993eae3b801","html_url":"https://github.com/opencodeco/hyperf-doctrine","commit_stats":null,"previous_names":["opencodeco/hyperf-doctrine"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/opencodeco/hyperf-doctrine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencodeco%2Fhyperf-doctrine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencodeco%2Fhyperf-doctrine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencodeco%2Fhyperf-doctrine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencodeco%2Fhyperf-doctrine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opencodeco","download_url":"https://codeload.github.com/opencodeco/hyperf-doctrine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencodeco%2Fhyperf-doctrine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419955,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["connection-pool","database","doctrine","hacktoberfest","hyperf","orm"],"created_at":"2024-08-02T20:00:44.747Z","updated_at":"2026-01-14T12:17:54.476Z","avatar_url":"https://github.com/opencodeco.png","language":"PHP","readme":"# Hyperf 🤝 Doctrine\n\nThis project provides an integration for the Doctrine ORM and the Hyperf framework.\n\n[![CI](https://github.com/opencodeco/hyperf-doctrine/actions/workflows/ci.yml/badge.svg)](https://github.com/opencodeco/hyperf-doctrine/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/opencodeco/hyperf-doctrine/branch/main/graph/badge.svg?token=YdK7pQfcOQ)](https://codecov.io/gh/opencodeco/hyperf-doctrine)\n![PHPStan](https://img.shields.io/badge/PHPStan-level%209-brightgreen.svg?style=flat)\n\n## Install\n\n### Set the OpenCodeCo repository\n```shell\ncomposer config repositories.opencodeco composer https://composer.opencodeco.dev\n```\n\n### Install with Composer\n```shell\ncomposer require opencodeco/hyperf-doctrine\n```\n\n## Setup\nYou should publish `hyperf/db` as this package uses it as the underlaying driver engine:\n```shell\nphp bin/hyperf.php vendor:publish hyperf/db\n```\n\n**⭐ This means that you have Doctrine ORM baked into Hyperf pools and connections lifecycle management free of charge** - *How awesome?*\n\nConfigure the database in `config/autoload/db.php`:\n```php\nreturn [\n    'default' =\u003e [\n        'driver' =\u003e 'pdo',\n        'host' =\u003e env('DB_HOST', 'localhost'),\n        'port' =\u003e env('DB_PORT', 3306),\n        'database' =\u003e env('DB_DATABASE', 'hyperf'),\n        'username' =\u003e env('DB_USERNAME', 'root'),\n        'password' =\u003e env('DB_PASSWORD', ''),\n        'charset' =\u003e env('DB_CHARSET', 'utf8mb4'),\n        'collation' =\u003e env('DB_COLLATION', 'utf8mb4_unicode_ci'),\n        'fetch_mode' =\u003e PDO::FETCH_ASSOC,\n        'pool' =\u003e [\n            'min_connections' =\u003e 1,\n            'max_connections' =\u003e 10,\n            'connect_timeout' =\u003e 10.0,\n            'wait_timeout' =\u003e 3.0,\n            'heartbeat' =\u003e -1,\n            'max_idle_time' =\u003e (float) env('DB_MAX_IDLE_TIME', 60),\n        ],\n        'options' =\u003e [\n            PDO::ATTR_CASE =\u003e PDO::CASE_NATURAL,\n            PDO::ATTR_ERRMODE =\u003e PDO::ERRMODE_EXCEPTION,\n            PDO::ATTR_ORACLE_NULLS =\u003e PDO::NULL_NATURAL,\n            PDO::ATTR_STRINGIFY_FETCHES =\u003e false,\n            PDO::ATTR_EMULATE_PREPARES =\u003e false,\n        ],\n    ],\n];\n```\n\nThen publish Hyperf Doctrine configurations:\n```shell\nphp bin/hyperf.php vendor:publish opencodeco/hyperf-doctrine\n```\n\nYou can edit Doctrine's Entity Manager settings in `config/autoload/doctrine.php`:\n```php\nreturn [\n    'connection' =\u003e [\n        'driverClass' =\u003e Hyperf\\Doctrine\\Driver::class,\n        'pool' =\u003e 'default',\n    ],\n    'config' =\u003e Doctrine\\ORM\\Tools\\Setup::createAnnotationMetadataConfiguration([__DIR__ . '/app']),\n];\n```\n\nIt will also publish a `cli-config.php` to `config/` so you can already run `vendor/bin/doctrine`, for example:\n```shell\nvendor/bin/doctrine orm:schema-tool:create\n```\n\n## Usage\nAt this time, you are ready to use Doctrine ORM with Hyperf.\n\nFor example, create an Entity as you would do regulary:\n```php\n/**\n * @ORM\\Entity()\n * @ORM\\Table(name=\"users\")\n */\nfinal class User\n{\n    public function __construct(\n        /**\n         * @ORM\\Id()\n         * @ORM\\Column(type=\"integer\")\n         * @ORM\\GeneratedValue(strategy=\"AUTO\")\n         */\n        public int $id,\n        /*\n         * @ORM\\Column(type=\"string\")\n         */\n        public string $name,\n        /**\n         * @ORM\\Column(type=\"string\")\n         */\n        public string $email,\n    ) {\n    }\n}\n```\n\nThen let dependency injection magic do the work to inject an `EntityManager` into your application:\n```php\n/**\n * @Controller(prefix=\"users\")\n */\nfinal class UsersController\n{\n    public function __construct(\n        private EntityManagerInterface $em,\n    ) {\n    }\n\n    /**\n     * @GetMapping(path=\"\")\n     */\n    public function index(RequestInterface $request, ResponseInterface $response)\n    {\n        return $this-\u003eem-\u003egetRepository(User::class)-\u003efindAll();\n    }\n}\n```\n\n**And that is it!**\n\nFeel free to contribute submiting issues and PRs.\n\n---\n\nMIT \u0026copy; 2023\n","funding_links":[],"categories":["Frameworks"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencodeco%2Fhyperf-doctrine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopencodeco%2Fhyperf-doctrine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencodeco%2Fhyperf-doctrine/lists"}