{"id":22862175,"url":"https://github.com/webforge-labs/webforge-doctrine-compiler","last_synced_at":"2025-10-20T07:31:49.277Z","repository":{"id":11686021,"uuid":"14197255","full_name":"webforge-labs/webforge-doctrine-compiler","owner":"webforge-labs","description":"Generate your doctrine entities metadata from a simple json file, including the php code for the entity","archived":false,"fork":false,"pushed_at":"2021-05-04T02:32:16.000Z","size":306,"stargazers_count":3,"open_issues_count":20,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T21:51:25.484Z","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/webforge-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2013-11-07T07:36:55.000Z","updated_at":"2023-12-30T12:26:43.000Z","dependencies_parsed_at":"2022-07-06T02:02:06.941Z","dependency_job_id":null,"html_url":"https://github.com/webforge-labs/webforge-doctrine-compiler","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/webforge-labs/webforge-doctrine-compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webforge-labs%2Fwebforge-doctrine-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webforge-labs%2Fwebforge-doctrine-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webforge-labs%2Fwebforge-doctrine-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webforge-labs%2Fwebforge-doctrine-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webforge-labs","download_url":"https://codeload.github.com/webforge-labs/webforge-doctrine-compiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webforge-labs%2Fwebforge-doctrine-compiler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263445975,"owners_count":23467652,"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":[],"created_at":"2024-12-13T10:12:35.458Z","updated_at":"2025-10-20T07:31:44.231Z","avatar_url":"https://github.com/webforge-labs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webforge-doctrine-compiler\n\n[![Build Status](https://travis-ci.org/webforge-labs/webforge-doctrine-compiler.png)](https://travis-ci.org/webforge-labs/webforge-doctrine-compiler)  \n[![Coverage Status](https://coveralls.io/repos/webforge-labs/webforge-doctrine-compiler/badge.png?branch=master)](https://coveralls.io/r/webforge-labs/webforge-doctrine-compiler?branch=master)  \n[![Latest Stable Version](https://poser.pugx.org/webforge/doctrine-compiler/version.png)](https://packagist.org/packages/webforge/doctrine-compiler)\n\nGenerate your doctrine entities metadata from a simple json file, including the php code for the entity\n\n## usage\n\nA very basic model (with one entity) could look like this:\n\n```json\n{\n  \"namespace\": \"ACME\\\\Blog\\\\Entities\",\n\n  \"entities\": [\n\n    {\n      \"name\": \"User\",\n  \n      \"properties\": {\n        \"id\": { \"type\": \"DefaultId\" },\n        \"email\": { \"type\": \"String\" }\n      }\n    }\n  ]\n}\n```\n\nThe compiler will create this entity for you:\n```php\n\u003c?php\n\nnamespace ACME\\Blog\\Entities;\n\nuse Doctrine\\ORM\\Mapping as ORM;\n\n/**\n * @ORM\\Entity\n * @ORM\\Table(name=\"users\")\n */\nclass User {\n\n  /**\n   * @ORM\\Id \n   * @ORM\\Column(type=\"integer\")\n   * @ORM\\GeneratedValue\n   */\n  protected $id;\n\n  /** \n   * @ORM\\Column(length=200) \n   */\n  protected $email;\n\n  public function __construct($email) {\n    $this-\u003eemail = $email;\n  }\n\n  /**\n   * @return string\n   */\n  public function getEmail() {\n    return $this-\u003eemail;\n  }\n  \n  /**\n   * @param string Email\n   * @chainable\n   */\n  public function setEmail($email) {\n    $this-\u003eemail = $email;\n    return $this;\n  }\n}\n\n```\n\nYou have the option to use this code and just copy n paste it into your (doctrine)-project. Another option is to put the json model into your project and include the compiler as a dev dependency. If someone changes the model, the entities can be recompiled. You just have to cross the generation-gap here:\n\n`CompiledUser.php`\n```php\n\u003c?php\n\nnamespace ACME\\Blog\\Entities;\n\nuse Doctrine\\ORM\\Mapping as ORM;\n\nabstract class CompiledUser {\n\n  /**\n   * @ORM\\Id \n   * @ORM\\Column(type=\"integer\")\n   * @ORM\\GeneratedValue\n   */\n  protected $id;\n\n  /** \n   * @ORM\\Column(length=200) \n   */\n  protected $email;\n\n  public function __construct($email) {\n    $this-\u003eemail = $email;\n  }\n\n  /**\n   * @return string\n   */\n  public function getEmail() {\n    return $this-\u003eemail;\n  }\n  \n  /**\n   * @param string Email\n   * @chainable\n   */\n  public function setEmail($email) {\n    $this-\u003eemail = $email;\n    return $this;\n  }\n}\n```\n\n`User.php`\n```php\n\u003c?php\nnamespace ACME\\Blog\\Entities;\n\n/**\n * @ORM\\Entity\n * @ORM\\Table(name=\"users\")\n */\nuse Doctrine\\ORM\\Mapping as ORM;\n\nclass User extends CompiledUser {\n\n  protected $somethingUserDefined;\n\n  public function __construct($email, $somethingUserDefined) {\n    parent::_construct($email);\n    $this-\u003esomethingUserDefined = $somethingUserDefined;\n  }\n}\n```\n\nThis way your developers should never touch the Compiled** - Entities and always alter the extended classes. This way you're able to easily add new properties to your entities, or change relations between them.\n\n## Installation\n\nThe best way to use the doctrine compiler is to install it as a development tool on your machine.\n\n```\ncomposer global require webforge/doctrine-compiler\n```\n\nI recommend to put the global composer bin directory (`~/.composer/vendor/bin` or `%APPDATA%\\composer\\vendor\\bin`) in your PATH.\n\n## Running\n\nYou can then compile your entities with the binary installed by composer. You have to provide the location of your json model file and the PSR-1 target-directory for your Entities.\n\n```\n~/.composer/vendor/bin/webforge-doctrine-compiler orm:compile etc/doctrine/model.json path/to/my/package/src/php\n```\n\nThis will create the entities within a PSR-1 named directory in src/php\n\n# Known Issues\n\n- OneToMany, self-referencing Assocations are not yet supported\n- the primary defaultId with name 'id' is hardcoded on many cases (you are encouraged to use such an id)\n\n\n# LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 webforge\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebforge-labs%2Fwebforge-doctrine-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebforge-labs%2Fwebforge-doctrine-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebforge-labs%2Fwebforge-doctrine-compiler/lists"}