Formateurs & Code
JSON en classe/DTO PHP
Strict-typed PHP DTO classes from a JSON sample.
Note de la rédaction
Understanding · Modern PHP DTOs are surprisingly tight.
Ce chapitre approfondi n'est actuellement disponible qu'en anglais. L'outil de conversion ci-dessus fonctionne dans votre langue ; le long article explicatif n'a pas encore été traduit.
Questions fréquentes
Quick answers.
›Which version of PHP is supported?
The generator targets PHP 8.1 and above, utilising readonly properties, constructor promotion, and strict type hints. You can manually adjust the output for older versions if required.
›How does it handle nested objects?
Nested JSON objects are automatically identified and generated as separate, linked PHP classes. This maintains a clean, modular structure where each object has its own typed definition.
›Does it support arrays of objects?
Yes. If an array of objects is detected, the tool generates a single class definition for those items and uses array type hinting in the parent class documentation.
›Is my JSON data secure?
Yes. The parsing and transformation happen locally within your browser's memory using JavaScript. Your JSON input and the resulting PHP code are never transmitted to a server.
Les internautes recherchent aussi
Outils similaires
More in this room.
- JSON en interface TypeScriptDéduisez les types à partir d'un exemple JSON et émettez des interfaces TS.
- JSON en classe C#Générez des classes POCO à partir d'un exemple JSON.
- JSON en POJO JavaÉmettez un POJO Java à partir d'un exemple JSON.
- JSON en dataclasse PythonDataclasses typées (avec Pydantic optionnel) à partir de JSON.
- JSON en struct GoStructs Go idiomatiques avec des tags `json:`.
- JSON en classe de données KotlinClasses de données concises pour tout exemple JSON.