{"id":14966544,"url":"https://github.com/panlatent/craft-enums","last_synced_at":"2026-03-04T03:30:51.908Z","repository":{"id":232782465,"uuid":"785117843","full_name":"panlatent/craft-enums","owner":"panlatent","description":"Generates all Fields, Section, Volume ... enums in Craft CMS","archived":false,"fork":false,"pushed_at":"2024-05-11T01:36:04.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T16:02:17.681Z","etag":null,"topics":["const","craftcms","enum","yii2","yii2-extension"],"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/panlatent.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":"2024-04-11T08:26:11.000Z","updated_at":"2025-03-07T01:26:47.000Z","dependencies_parsed_at":"2024-09-14T02:54:44.268Z","dependency_job_id":null,"html_url":"https://github.com/panlatent/craft-enums","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"28d73efb76a424e122b469c9b16076ccede065b5"},"previous_names":["panlatent/craft-enums"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/panlatent/craft-enums","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlatent%2Fcraft-enums","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlatent%2Fcraft-enums/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlatent%2Fcraft-enums/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlatent%2Fcraft-enums/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panlatent","download_url":"https://codeload.github.com/panlatent/craft-enums/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlatent%2Fcraft-enums/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30070743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T03:25:38.285Z","status":"ssl_error","status_checked_at":"2026-03-04T03:25:05.086Z","response_time":59,"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":["const","craftcms","enum","yii2","yii2-extension"],"created_at":"2024-09-24T13:36:34.251Z","updated_at":"2026-03-04T03:30:51.884Z","avatar_url":"https://github.com/panlatent.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Craft Enums\n============\n\nThe Craft Enum is a PHP enum generator. \nIt generates all Fields, Section, Volume ... handles write to code as cases.\n\n```php\n// Get a section\n$section = Section::Posts-\u003esection() \n// Create a entry with sectionId\n$entry = Section::Posts-\u003enew()\n// Entry query with section\n$entryQuery = Section::Post-\u003efind();\n// Replace string handle (Not recommended)\n$section = Craft::$app-\u003esecionts-\u003egetSectionByHandle(Section::Posts-\u003evalue);\n```\n\n    Note: You cannot use PHP enumerations to directly replace string. You should write `getSectionByHandle(Section::Posts-\u003evalue)` instead of `getSectionByHandle(Section::Posts)`(error).\n          Maybe, never try to use enums instead of strings or constants, but use the convenience methods of the enum class.\n\nRequirements\n------------\n+ PHP 8.2\n+ Craft CMS 4.3.5 or later.\n\nInstallation\n------------\n\n```bash\ncomposer require panlatent/craft-enum --dev\n```\n\nUsage\n------\n\n### Generate\n\n+ Manual\n\nReference: [CraftCMS Docs](https://craftcms.com/docs/5.x/extend/generator.html#usage)\n\n```bash\nphp craft make enums\n```\n\nGenerate enums to `src/enums`\n```bash\nddev craft make enums --path=src\n```\n\n+ Automatic\n\nIt is recommended that you register events to generate real-time:\n\n```php\nuse panlatent\\craft\\enums\\Enums;\nEvent::on(ProjectConfig::class, ProjectConfig::EVENT_AFTER_WRITE_YAML_FILES), function() {\n    (new \\Symfony\\Component\\Process\\Process(['php', 'craft', 'make', 'enums', '--path=src', '--interactive=1'], Craft::getAlias('@root'), [Enums::DISABLE_INTERACTIVE =\u003e true]))-\u003emustRun();\n});\n```\nWe use the `Symfony Process` component to run build commands when the project changes, using `--interactive=1` and `Enums::DISABLE_INTERACTIVE =\u003e true` in order to bypass CraftCMS limitation.\n\n### Coding\n\nSee generate codes.\n\n\n\nReferences\n-----------\n\n\n\n\nLicense\n-------\nThe project is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanlatent%2Fcraft-enums","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanlatent%2Fcraft-enums","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanlatent%2Fcraft-enums/lists"}