{"id":36981538,"url":"https://github.com/jdecool/enum-doctrine","last_synced_at":"2026-01-13T22:51:23.948Z","repository":{"id":56997498,"uuid":"319473019","full_name":"jdecool/enum-doctrine","owner":"jdecool","description":"A Doctrine type that maps column values to enum objects using jdecool/enum ","archived":true,"fork":false,"pushed_at":"2022-01-24T20:10:24.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T14:52:07.435Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/jdecool.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":"2020-12-07T23:41:55.000Z","updated_at":"2023-02-02T09:14:44.000Z","dependencies_parsed_at":"2022-08-21T14:50:13.810Z","dependency_job_id":null,"html_url":"https://github.com/jdecool/enum-doctrine","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jdecool/enum-doctrine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fenum-doctrine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fenum-doctrine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fenum-doctrine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fenum-doctrine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdecool","download_url":"https://codeload.github.com/jdecool/enum-doctrine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fenum-doctrine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28402159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: 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":[],"created_at":"2026-01-13T22:51:23.221Z","updated_at":"2026-01-13T22:51:23.942Z","avatar_url":"https://github.com/jdecool.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Doctrine Enum Type\n==================\n\n[![Build Status](https://github.com/jdecool/enum-doctrine/workflows/CI/badge.svg)](https://github.com/jdecool/enum-doctrine/actions?query=workflow%3ACI)\n[![Latest Stable Version](https://poser.pugx.org/jdecool/enum-doctrine/v/stable.png)](https://packagist.org/packages/jdecool/enum-doctrine)\n\nThis package provides a base implementation to define doctrine entity column types that are mapped to `JDecool\\Enum\\Enum` objects (of [`jdecool/enum`](https://github.com/jdecool/enum) package).\n\nThis is a port of [`acelaya/doctrine-enum-type`](https://github.com/acelaya/doctrine-enum-type).\n\n## Deprecated\n\n⚠️ This project is no longer actively maintained.\n\nNative enum arrived to PHP in version 8.1: https://www.php.net/enumerations\nIf your project is running PHP 8.1+ or your library has it as a minimum requirement you should use it instead of this library.\n\n## Installation\n\nInstall it using [Composer](https://getcomposer.org):\n\n```bash\ncomposer require jdecool/enum-doctrine\n```\n\n## Usage\n\nThis package provides a `JDecool\\Enum\\Doctrine\\EnumType` class that extends `Doctrine\\DBAL\\Types\\Type`. You can use it to easily map type names to concrete Enums.\n\nThe `EnumType` class will be used as the doctrine type for every property that is an enumeration.\n\n```php\nuse JDecool\\Enum\\Enum;\n\nclass MyEnum extends Enum\n{\n    public const ENUM_1 = 'value_1';\n    protected const ENUM_2 = 'value_2';\n    private const ENUM_3 = 'value_3';\n}\n```\n\nThen, you can map the enum to your entity.\n\n```php\nclass User\n{\n    // ...\n\n    /**\n     * @var MyEnum\n     *\n     * @ORM\\Column(type=MyEnum::class, length=10)\n     */\n    protected $action;\n\n    // ...\n}\n```\n\nThe column type of the property is the FQCN of the `MyEnum` enum. To get this working, you have to register the concrete column types, using the `JDecool\\Enum\\Doctrine\\EnumType::registerEnumType` static method.\n\n```php\n// in bootstrapping code\nuse JDecool\\Enum\\Doctrine\\EnumType;\n\nEnumType::registerEnumType(MyEnum::class);\n\n// Don't forget to register the enums for schema operations\n$platform = $em-\u003egetConnection()-\u003egetDatabasePlatform();\n$platform-\u003eregisterDoctrineTypeMapping('VARCHAR', MyEnum::class);\n```\n\nAlternatively you can use the `JDecool\\Enum\\Doctrine\\EnumType::registerEnumTypes`, which expects an array of enums to register.\n\n```php\n// ...\n\nuse JDecool\\Enum\\Doctrine\\EnumType;\n\nEnumType::registerEnumTypes([\n    MyEnum::class,\n    'php_enum_type' =\u003e MyEnum::class,\n]);\n```\n\nIf you use Doctrine with Symfony:\n\n```yaml\n# config/packages/doctrine.yaml\ndoctrine:\n    dbal:\n        types:\n            uuid: JDecool\\Enum\\Doctrine\\EnumType\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdecool%2Fenum-doctrine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdecool%2Fenum-doctrine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdecool%2Fenum-doctrine/lists"}