idimensionz / entity-generator-bundle
Installs: 6 775
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: ^7.4
- ext-ctype: *
- ext-iconv: *
- doctrine/doctrine-bundle: ^1.9
- doctrine/orm: ^2.6
- symfony/cache: ^3.4|^4.4
- symfony/config: ^3.4|^4.4
- symfony/console: ^3.4|^4.4
- symfony/debug: ^3.4|^4.4
- symfony/dependency-injection: ^3.4|^4.4
- symfony/doctrine-bridge: ^3.4|^4.4
- symfony/dotenv: ^3.4|^4.4
- symfony/event-dispatcher: ^3.4|^4.4
- symfony/filesystem: ^3.4|^4.4
- symfony/finder: ^3.4|^4.4
- symfony/flex: ^1.1
- symfony/framework-bundle: ^3.4|^4.4
- symfony/http-foundation: ^3.4|^4.4
- symfony/http-kernel: ^3.4|^4.4
- symfony/routing: ^3.4|^4.4
- symfony/symfony: ^3.4|^4.4
- symfony/twig-bridge: ^3.4|^4.4
- symfony/twig-bundle: ^3.4|^4.4
- symfony/yaml: ^3.4|^4.4
- twig/twig: ^2.5
Requires (Dev)
- phake/phake: ^3.1
- symfony/test-pack: ^1.0
README
Symfony service and console command that does a simple reverse engineer of MySQL tables into entity classes.
Join the entity-generator channel on iDimensionz's Community Slack to ask questions, share tips and meet others using this software.
Configuration
- Add the following to registerBundles() in your kernel:
new iDimensionz\EntityGeneratorBundle\EntityGeneratorBundle(),
- Add the following to services.yml:
idimensionz.mysql_column_definition_provider:
class: iDimensionz\EntityGeneratorBundle\Provider\MysqlColumnDefinitionProvider
idimensionz.entity_creator_service:
class: iDimensionz\EntityGeneratorBundle\Service\EntityCreatorService
arguments: ["@idimensionz.mysql_column_definition_provider", "@twig"]
idimensionz-entity-generator-command:
class: iDimensionz\EntityGeneratorBundle\Command\GenerateEntityCommand
arguments: ["@idimensionz.entity_creator_service", ~]
- Add "%kernel.project_dir%/vendor/idimensionz/entity-generator-bundle/templates" to your twig.paths in config.yml.
- Profit!
How to Run the Console Command
The console command take 3 parameters:
- schema-name
- table-name
- entity-class-name
Here's an example of how you would create an entity class for the COLUMNS table in the MySQL information_schema database:
bin/console idimensionz:generate:entity --schema-name=information_schema --table-name=PROFILING --entity-class-name=Profiling
The command will output the class code to the screen where you can copy and paste it into your favorite IDE.
Note: If using PhpStorm, you can easily generate getters and setters with PHP 7 parameter and return value type-hinting as well as doc blocks.
To-Do
We'd like to implement the following improvements. Feel free to submit a PR if you want to help out with these.
- Add twig blocks to the template to make it easier to customize certain sections.
- Add the ability to specify a bundle where the entity file would be created.