{"id":18486147,"url":"https://github.com/mathsgod/formkit-php","last_synced_at":"2025-05-13T22:13:04.165Z","repository":{"id":188845216,"uuid":"679534134","full_name":"mathsgod/formkit-php","owner":"mathsgod","description":"A PHP library for generating FormKit Schema from PHP classes.","archived":false,"fork":false,"pushed_at":"2023-08-18T09:05:24.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-13T09:03:24.922Z","etag":null,"topics":["formkit","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathsgod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-17T04:10:27.000Z","updated_at":"2023-08-17T08:28:37.000Z","dependencies_parsed_at":"2023-08-17T05:26:18.763Z","dependency_job_id":"8bce77ec-72ca-4cd2-973c-2322406263e2","html_url":"https://github.com/mathsgod/formkit-php","commit_stats":null,"previous_names":["mathsgod/formkit-php"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fformkit-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fformkit-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fformkit-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fformkit-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathsgod","download_url":"https://codeload.github.com/mathsgod/formkit-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036843,"owners_count":22003654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["formkit","php"],"created_at":"2024-11-06T12:48:01.207Z","updated_at":"2025-05-13T22:12:59.156Z","avatar_url":"https://github.com/mathsgod.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# formkit-php\n\nA PHP library for generating \u003ca href=\"https://formkit.com/essentials/schema\"\u003eFormKit Schema\u003c/a\u003e from PHP classes.\n\n\n## Installation\n\nInstall via composer:\n\n```bash\ncomposer require mathsgod/formkit-php\n```\n\n## Usage\n\n### Basic Usage\n\n```php\n\n$schema = new FormKit\\Schema();\n$schema-\u003eappendHTML(\"\u003cform-kit label='hello' type='text'/\u003e\");\necho json_encode($schema, JSON_PRETTY_PRINT);\n```\n\noutput:\n\n```json\n[\n    {\n        \"$formkit\": \"text\",\n        \"label\": \"hello\"\n    }\n]\n```\n\n### Simple element \n\n```php\n\n$schema = new FormKit\\Schema();\n$schema-\u003eappendElement(\"div\")-\u003eappendElement(\"span\")-\u003eappendHTML(\"hello\");\necho json_encode($schema, JSON_PRETTY_PRINT);\n```\n\noutput:\n\n```json\n[\n    {\n        \"$el\": \"div\",\n        \"children\": [\n            {\n                \"$el\": \"span\",\n                \"children\": [\n                    \"hello\"\n                ]\n            }\n        ]\n    }\n]\n```\n\n### Component\n\n```php\n\n$schema = new FormKit\\Schema();\n$card=$schema-\u003eappendComponent(\"q-card\");\n$card-\u003esetAttribute(\"flat\",\"\");\n\necho json_encode($schema, JSON_PRETTY_PRINT);\n    \n```\n\noutput:\n\n```json\n[\n    {\n        \"$cmp\": \"q-card\",\n        \"props\": {\n            \"flat\": true\n        }\n    }\n]\n```\n\n\n### Registering custom Vue components\n\n```php\n\n$schema = new FormKit\\Schema();\n$schema-\u003eregisterClass(\"q-card\", FormKit\\Component::class);\n$schema-\u003eappendHTML(\"\u003cq-card flat\u003eHello\u003c/q-card\u003e\");\n\necho json_encode($schema, JSON_PRETTY_PRINT);\n\n```\n\noutput:\n\n```json\n[\n    {\n        \"$cmp\": \"q-card\",\n        \"props\": {\n            \"flat\": true\n        },\n        \"children\": [\n            \"Hello\"\n        ]\n    }\n]\n```\n\n\n### Registering custom FormKit input components\n\n```php\n$schema = new FormKit\\Schema();\n$schema-\u003eregisterInputClass(\"my-input\", FormKit\\FormKitInputs::class);\n$schema-\u003eappendHTML(\"\u003cform-kit label='My custom input' type='my-input'/\u003e\");\necho json_encode($schema, JSON_PRETTY_PRINT);\n```\n\noutput:\n\n```json\n[\n    {\n        \"$formkit\": \"my-input\",\n        \"label\": \"My custom input\"\n    }\n]\n```\n\n\n### Custom component class\n\n```php\n\nclass QBtn extends FormKit\\Component\n{\n\n    public function setLabel($label)\n    {\n        $this-\u003esetAttribute(\"label\", $label);\n    }\n}\n\n$schema = new FormKit\\Schema();\n$schema-\u003eregisterClass(\"q-btn\", QBtn::class);\n$node=$schema-\u003eappendHTML(\"\u003cq-btn label='Hello'/\u003e\")[0]; //$node=$schema-\u003eappendComponent(\"q-btn\");\n\n//change label\n$node-\u003esetLabel(\"World\");\n\necho json_encode($schema, JSON_PRETTY_PRINT);\n\n```\n\noutput:\n\n```json\n[\n    {\n        \"$cmp\": \"q-btn\",\n        \"props\": {\n            \"label\": \"World\"\n        }\n    }\n]\n```\n\n\n### Append child nodes\n\n```php\n$schema = new FormKit\\Schema();\n$e = $schema-\u003eappendHTML(\"\u003cdiv\u003e\u003c/div\u003e\")[0];\n$e-\u003eappend($schema-\u003ecreateElement(\"div\", \"hello\"));\necho json_encode($schema, JSON_PRETTY_PRINT);\n\n```\n\noutput:\n\n```json\n[\n    {\n        \"$el\": \"div\",\n        \"children\": [\n            {\n                \"$el\": \"div\",\n                \"children\": [\n                    \"hello\"\n                ]\n            }\n        ]\n    }\n]\n```\n\n### Append child nodes from HTML\n\n```php\n$schema = new FormKit\\Schema();\n$e = $schema-\u003eappendHTML(\"\u003cdiv\u003e\u003c/div\u003e\")[0];\n$e-\u003eappendHTML(\"\u003cdiv\u003ehello\u003c/div\u003e\");\necho json_encode($schema, JSON_PRETTY_PRINT);\n\n```\n\noutput:\n\n```json\n[\n    {\n        \"$el\": \"div\",\n        \"children\": [\n            {\n                \"$el\": \"div\",\n                \"children\": [\n                    \"hello\"\n                ]\n            }\n        ]\n    }\n]\n```\n\n\n### Loops\n\n```php\n\n$group = $schema-\u003eappendHTML(\"\u003cform-kit type='group'/\u003e\")[0];\n$group-\u003esetAttribute(\":value\", json_encode([\n    \"cities\" =\u003e [\"Hong Kong\", \"Taiwan\", \"China\"]\n]));\n\n$div = $group-\u003eappendElement(\"div\");\n\n$div-\u003efor([\"item\", \"key\", '$value.cities']);\n\n$div-\u003eappendHTML('$item');\n\necho json_encode($schema, JSON_PRETTY_PRINT);\n\n```\n\noutput:\n\n```json\n[\n    {\n        \"$formkit\": \"group\",\n        \"label\": \"Group\",\n        \"value\": {\n            \"cities\": [\n                \"Hong Kong\",\n                \"Taiwan\",\n                \"China\"\n            ]\n        },\n        \"children\": [\n            {\n                \"$el\": \"div\",\n                \"children\": [\n                    \"$item\"\n                ],\n                \"for\": [\n                    \"item\",\n                    \"key\",\n                    \"$value.cities\"\n                ]\n            }\n        ]\n    }\n]\n```\n\n    ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathsgod%2Fformkit-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathsgod%2Fformkit-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathsgod%2Fformkit-php/lists"}