{"id":20892905,"url":"https://github.com/a5sys/doctrinetraitbundle","last_synced_at":"2026-02-22T21:03:55.413Z","repository":{"id":56938905,"uuid":"56300236","full_name":"A5sys/DoctrineTraitBundle","owner":"A5sys","description":"Generate the entities stub methods in a trait","archived":false,"fork":false,"pushed_at":"2019-02-27T08:19:46.000Z","size":23,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-15T22:12:39.042Z","etag":null,"topics":["doctrine","getters","setters","symfony-bundle"],"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/A5sys.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":"2016-04-15T07:27:33.000Z","updated_at":"2018-07-23T12:42:00.000Z","dependencies_parsed_at":"2022-08-21T01:40:21.657Z","dependency_job_id":null,"html_url":"https://github.com/A5sys/DoctrineTraitBundle","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A5sys%2FDoctrineTraitBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A5sys%2FDoctrineTraitBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A5sys%2FDoctrineTraitBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A5sys%2FDoctrineTraitBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/A5sys","download_url":"https://codeload.github.com/A5sys/DoctrineTraitBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225156983,"owners_count":17429701,"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":["doctrine","getters","setters","symfony-bundle"],"created_at":"2024-11-18T10:14:14.469Z","updated_at":"2026-02-22T21:03:50.384Z","avatar_url":"https://github.com/A5sys.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DoctrineTraitBundle\nGenerate the entities stub methods in a trait\n\nThe generated traits contains the getters/setters generated by the doctrine generator.\nThe trait should be used in your entity.\n\n# Benefits\n\nYour entities contains only the usefull information:\n\n* The doctrine columns and relationships\n* The getters/setters that have been modified\n* The custom methods\n\nAll basics getters/setters are in the trait.\n\n# Composer\n\nUse composer to get the bundle\n\n    composer require --dev \"a5sys/doctrine-trait-bundle\"\n\n# Activate the bundle\n\nIn the AppKernel, activate the bundle for the dev environment\n\n        if (in_array($this-\u003egetEnvironment(), array('dev'))) {\n            ...\n            $bundles[] = new A5sys\\DoctrineTraitBundle\\DoctrineTraitBundle();\n        }\n\n# Usage\n\n## Generate traits\n\nRun the command\n\n        php app/console generate:doctrine:traits AppBundle\\\\Entity\n\nOr this one if you want to act on a single entity\n\n        php app/console generate:doctrine:traits \"AppBundle:MyEntity\"\n\nThose commands will generate the trait(s) in the /src/AppBundle/Entity/Traits directory\n\n## Use custom method\n\n* Go in the trait related to your entity\n* Cut the method\n* Go in your entity\n* Paste the method\n* Update the method\n* The command will not re-generate this method because it is already defined in entity\n\n## Exemple\n\n* Create your entity (User) without the getters/setters\n* Run the command\n* Add the trait to your entity\n* You are done\n\n### The entity\n\n        namespace AppBundle/Entity;\n\n        class User\n        {\n            use AppBundle/Entity/Traits/UserTrait;\n\n            /**\n             * @ORM\\Id\n             * @ORM\\GeneratedValue\n             * @ORM\\Column(type=\"integer\", nullable=false)\n             */\n            protected $id;\n\n            /**\n             * @ORM\\Column(type=\"string\", length=50, nullable=false)\n             */\n            protected $name;\n        }\n\n### The trait\n\n        namespace AppBundle/Entity/Traits;\n\n        /**\n         * User\n         */\n        trait UserTrait\n        {\n\n            /**\n             *\n             * @param integer $id\n             */\n            public function setId($id)\n            {\n                $this-\u003eid = $id;\n            }\n\n            /**\n             *\n             * @return integer\n             */\n            public function getId()\n            {\n                return $this-\u003eid;\n            }\n\n            /**\n             *\n             * @param string $name\n             */\n            public function setName($name)\n            {\n                $this-\u003ename = $name;\n            }\n\n            /**\n             * Get the name\n             *\n             * @return string\n             */\n            public function getName()\n            {\n                return $this-\u003ename;\n            }\n        }\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa5sys%2Fdoctrinetraitbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa5sys%2Fdoctrinetraitbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa5sys%2Fdoctrinetraitbundle/lists"}