{"id":15296453,"url":"https://github.com/neutron-pro/symfony-normalizer-enum-php","last_synced_at":"2026-02-14T17:31:17.780Z","repository":{"id":57025797,"uuid":"384255364","full_name":"Neutron-Pro/symfony-normalizer-enum-php","owner":"Neutron-Pro","description":"Added Symfony normalizer for the enumeration system designed to be as close to PHP 8.1 for earlier versions.","archived":false,"fork":false,"pushed_at":"2021-07-09T20:05:24.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-07-18T13:49:38.680Z","etag":null,"topics":["doctrine","php","php-enum","php-library","php7","php8","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Neutron-Pro.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-07-08T21:46:26.000Z","updated_at":"2021-07-09T20:01:33.000Z","dependencies_parsed_at":"2022-08-23T16:20:33.120Z","dependency_job_id":null,"html_url":"https://github.com/Neutron-Pro/symfony-normalizer-enum-php","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Neutron-Pro/symfony-normalizer-enum-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neutron-Pro%2Fsymfony-normalizer-enum-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neutron-Pro%2Fsymfony-normalizer-enum-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neutron-Pro%2Fsymfony-normalizer-enum-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neutron-Pro%2Fsymfony-normalizer-enum-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neutron-Pro","download_url":"https://codeload.github.com/Neutron-Pro/symfony-normalizer-enum-php/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neutron-Pro%2Fsymfony-normalizer-enum-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274195572,"owners_count":25239147,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","php","php-enum","php-library","php7","php8","symfony"],"created_at":"2024-09-30T18:10:33.305Z","updated_at":"2026-02-14T17:31:17.751Z","avatar_url":"https://github.com/Neutron-Pro.png","language":"PHP","readme":"# Symfony Normalizer Enum Type\n\n---\n\n## Read the enum php doc:\n\n\u003e https://github.com/Neutron-Pro/enum-php\n\n---\n\n## Installation\n\n```\ncomposer require neutronstars/symfony-normalizer-enum-php\n```\n\n### Add doctrine:\n\n```\ncomposer require neutronstars/doctrine-enum-php-type\n```\n\n\u003e https://github.com/Neutron-Pro/doctrine-enum-php-type\n\n---\n\n### Example for serialize an object entity with an enum field:\n\n```php\n/**\n * @method static self WAITING()\n * @method static self PUBLISHED()\n */\nclass MyStringEnum extends \\NeutronStars\\Enum\\Enum {\n  public const WAITING   = 'Waiting';\n  public const PUBLISHED = 'Published';\n}\n\n/**\n * @Entity()\n */\nclass Post {\n    /**\n     * @ORM\\Id\n     * @ORM\\GeneratedValue\n     * @ORM\\Column(type=\"integer\") \n     * @Groups([\"post:details\"]) \n     * @var int \n     */\n     private $id;\n     \n     // ... Other field (name, createdAt, updatedAt etc..)\n     \n     /**\n      * For the customs type, please check the doctrine enum type documentation.\n      * @ORM\\Column(type=\"my_string_enum\")\n     *  @Groups([\"post:details\"]) \n      * @var MyStringEnum \n      */\n      private $state;\n      \n      public function __construct() {\n        $this-\u003estate = MyStringEnum::WAITING();\n      }\n      \n      // ... All methods implemented.\n}\n\n/**\n * @Route(\"/posts\", name=\"list_post\")\n */\nclass ListPostController {\n\n    /** @var PostRepository PostRepository */\n    private $postRepository;\n    \n    public function __construct(PostRepository $postRepository) {\n        $this-\u003epostRepository = $postRepository;\n    }\n\n    public function __invoke(): JSONResponse\n    {\n        $serializer = new \\Symfony\\Component\\Serializer\\Serializer([\n            new \\NeutronStars\\Symfony\\Enum\\Normalizer\\EnumNormalizer(MyStringEnum::class)\n        ], [new \\Symfony\\Component\\Serializer\\Encoder\\JsonEncode()]);\n        \n        return new JSONResponse(\n            $serializer-\u003enormalize(\n                $this-\u003epostRepository-\u003efindAll(),\n                null,\n                [ 'groups' =\u003e ['post:details'] ] \n            )\n        );\n    }\n}\n\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneutron-pro%2Fsymfony-normalizer-enum-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneutron-pro%2Fsymfony-normalizer-enum-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneutron-pro%2Fsymfony-normalizer-enum-php/lists"}