Would you like to build lightweight Transfer Objects (TO) easily? You're in the right place!
Imagine you have an array:
$data = [
'firstName' => 'Jan',
'lastName' => 'Kowalski'
];
TO facade method helps to convert array into YML
definition file:
Customer:
firstName:
type: string
lastName:
type: string
Generator console command builds TO based on definition file:
$customerTransfer = new CustomerTransfer();
$customerTransfer->firstName = 'Jan';
$customerTransfer->lastName = 'Kowalski';
How it works in action can be found on Wiki:
- Try Sample to generate Definition files
- Try Sample to generate TOs
- Try Advanced Sample to generate TOs
- Interface methods: implements
fromArray()
,toArray()
- Standard interfaces: implements
IteratorAggregate
,JsonSerializable
, andCountable
- Lightweight: TO includes only data without any business logic
- Nullable: supports both attribute types nullable and not nullable (
required:
) - BackedEnum: supports
BackedEnum
- Adaptable: compatible with custom Data Transfer Object (DTO) implementation
Composer installation:
$ composer require picamator/transfer-object
Run command bellow to generate Transfer Objects:
$ ./vendor/bin/generate-transfer [-c|--configuration CONFIGURATION]
Please check Wiki for more details:
Facade interface DefinitionGeneratorFacadeInterface
is used to generate YML
definition file
based on array.
Please check Wiki for more details:
Many thanks for your contribution, supports, feedback and simply using Transfer Object Generator!
If you find this project useful, please add a star to the repository. Follow the project to stay updated with all activities. If you have suggestions for improvements or new features, feel free to create an issue or submit a pull request. Here is a Contribution Guide.
Please note that this project is released with a Code of Conduct. By participating in this project and its community, you agree to abide by those terms.
Transfer Object Generator is free and open-source software licensed under the MIT License. For more details, please see the LICENSE file.