tomaskynicky/entity-creator
Composer 安装命令:
composer require tomaskynicky/entity-creator
包简介
Array to Entity
README 文档
README
Array to Entity and Repository is a powerful Composer package that transforms Array data into PHP entities with ease. With just a few steps, it parses Array inputs and auto-generates entity objects, simplifying data handling for applications that work with structured Array data. Streamline your workflow and keep your code clean and efficient with * entityCreator*.
🎉 Features
- Time saved: No more creating entities via console!
- Automated Entity Creation: Converts Array data directly into PHP entity classes.
- Seamless Array Parsing: Easily parses Array inputs, saving time on data transformation.
📦 Installation
Install via Composer:
composer require tomaskynicky/entity-creator:dev-main
📄 License
This package is open-source software licensed under the [MIT license]
⌨️️ Example
<?php declare(strict_types = 1); namespace App\Command; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Tomaskynicky\EntityCreator\DTO\EntityDTO; use Tomaskynicky\EntityCreator\DTO\FieldsDTO; use Tomaskynicky\EntityCreator\Enum\DataType; use Tomaskynicky\EntityCreator\IndexEntityCreator; #[AsCommand(name: 'app:create-entities')] class CreateEntitiesCommand extends Command { protected function configure(): void { } protected function execute(InputInterface $input, OutputInterface $output): int { $arrayData = [ new EntityDTO( name: 'User', fields: [ new FieldsDTO( name: 'id', type: DataType::ID, ), new FieldsDTO( name: 'name', type: DataType::BOOLEAN, length: '255', nullable: true ) ] ), ]; $indexEntityCreator = new IndexEntityCreator(); $indexEntityCreator->index($arrayData); $output->writeln("Success!"); return Command::SUCCESS; /* Write this in console php bin/console app:create-entities(create Entity and Repository) and this php bin/console make:migration for create migration */ } }
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-12