alexnguetcha / json-to-class
simple tool to create php class from json file.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
pkg:composer/alexnguetcha/json-to-class
This package is auto-updated.
Last update: 2025-10-21 06:27:24 UTC
README
simple tool to create php class from json file.
Example:
{
"class_name": "post",
"class_attrs": {
"id": {
"type": "int",
"visibility": "private"
},
"id_member": {
"type": "int",
"visibility": "private"
},
"content": {
"type": "string",
"visibility": "private"
},
"create_at": {
"type": "DateTime",
"visibility": "private"
}
}
}
$jtc = new JsonToClass(__DIR__."\\post.json"); $jtc->toFile();
Output:
//Post.php <?php class Person { private $name; private $old; private $sick; public function __construct(string $name, int $old, bool $sick) { $this->name = $name; $this->old = $old; $this->sick = $sick; } public function getName(): string { return $this->name; } public function getOld(): int { return $this->old; } public function isSick(): bool { return $this->sick; } public function setName(string $name):self { $this->name = $name; return $this; } public function setOld(int $old):self { $this->old = $old; return $this; } public function setSick(bool $sick):self { $this->sick = $sick; return $this; } }