{"id":32471223,"url":"https://github.com/rougin/dextra","last_synced_at":"2026-07-15T10:32:59.131Z","repository":{"id":303043687,"uuid":"1014235678","full_name":"rougin/dextra","owner":"rougin","description":"\"Ready-to-eat\" CRUD for PHP frontend.","archived":false,"fork":false,"pushed_at":"2026-05-23T16:39:50.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-30T22:10:28.046Z","etag":null,"topics":["php-crud","php-ui","ui-template"],"latest_commit_sha":null,"homepage":"https://roug.in/dextra/","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/rougin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-05T10:08:17.000Z","updated_at":"2026-05-23T16:38:23.000Z","dependencies_parsed_at":"2025-07-05T10:45:09.593Z","dependency_job_id":"faf06e8a-d7d9-49cb-a7e2-f58c70f08efe","html_url":"https://github.com/rougin/dextra","commit_stats":null,"previous_names":["rougin/dexterine","rougin/dextra"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rougin/dextra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdextra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdextra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdextra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdextra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rougin","download_url":"https://codeload.github.com/rougin/dextra/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdextra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35501664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-15T02:00:06.706Z","response_time":131,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["php-crud","php-ui","ui-template"],"created_at":"2025-10-26T16:57:01.590Z","updated_at":"2026-07-15T10:32:59.126Z","avatar_url":"https://github.com/rougin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dextra\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]][link-license]\n[![Build Status][ico-build]][link-build]\n[![Coverage Status][ico-coverage]][link-coverage]\n[![Total Downloads][ico-downloads]][link-downloads]\n\n`Dextra` is a PHP utility package that provides templates based on [alpine.js](https://alpinejs.dev/) for handling frontend CRUD.\n\n``` html\n\u003cscript type=\"text/javascript\"\u003e\n\u003c?= $depot = new Depot('items') ?\u003e\n\n\u003c?= $depot-\u003ewithInit() ?\u003e\n\n\u003c?= $depot-\u003ewithLoad(10)-\u003esetLink('/v1/items') ?\u003e\n\n\u003c?= $depot-\u003ewithStore()\n  -\u003eaddField('name')\n  -\u003esetAlert('Created!', 'Item created.')\n  -\u003esetLink('/v1/items') ?\u003e\n\u003c/script\u003e\n```\n\n## Installation\n\nInstall the package using [Composer](https://getcomposer.org/):\n\n``` bash\n$ composer require rougin/dextra\n```\n\n## Basic usage\n\nUse the `Depot` class to initialize the CRUD methods:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\u003c?php $depot = new Depot('items') ?\u003e\n\n// ...\n\u003c/script\u003e\n```\n\nThen use the available methods below once defined:\n\n### withInit\n\nCreates an `init` method. This method initializes any defined `Select` elements using [tom-select](https://tom-select.js.org/). After initialization, it calls the `load` method with the initial page number to fetch data:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithInit(1) ?\u003e\n\u003c/script\u003e\n```\n\n### withLoad\n\nCreates the `load` method. This method fetches paginated data from a `GET` request. Upon receiving a response, it updates the component's `items` data property with the fetched data and the `limit` data property with the expected items per page (e.g., `10`):\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithLoad(10)\n  -\u003esetLink($url-\u003eset('/v1/items')) ?\u003e\n\u003c/script\u003e\n```\n\nIt also provides configuration for `page` and `limit` keys by using `setPageKey` and `setLimitKey` methods respectively. The default values are `p` for `page` and `l` for `limit`:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithLoad(10)\n  -\u003esetPageKey('p')\n  -\u003esetLimitKey('l')\n  -\u003esetLink($url-\u003eset('/v1/items')) ?\u003e\n\u003c/script\u003e\n```\n\n### withStore\n\nCreates a `store` method. This is used for sending a `POST` request to the specified link to create a new item. It collects data from the defined fields, and shows an alert upon successful creation before reloading the data:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithStore()\n  -\u003eaddField('name')\n  -\u003eaddField('detail')\n  -\u003esetAlert('Item created!', 'Item successfully created.')\n  -\u003esetLink($url-\u003eset('/v1/items')) ?\u003e\n\u003c/script\u003e\n```\n\n### withEdit\n\nCreates an `edit` method. This method is used to populate a modal with the data of a selected item. It takes an `item` object as a parameter and assigns its properties to the corresponding fields in the modal. It can also show or hide other modals:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithEdit()\n  -\u003eaddField('name')\n  -\u003eaddField('detail')\n  -\u003eaddField('id')\n  -\u003eshowModal('item-detail-modal') ?\u003e\n\u003c/script\u003e\n```\n\n### withUpdate\n\nCreates an `update` method. This method is used for sending a `PUT` request to the specified link to update an existing item. It collects data from the defined fields, includes the item's ID in the request, and shows an alert upon successful update before reloading the data:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithUpdate()\n  -\u003eaddField('name')\n  -\u003eaddField('detail')\n  -\u003esetAlert('Item updated!', 'Item successfully updated.')\n  -\u003esetLink($url-\u003eset('/v1/items')) ?\u003e\n\u003c/script\u003e\n```\n\n### withTrash\n\nCreates a `trash` method. This method is used to populate a modal for confirming the deletion of an item. It takes an `item` object as a parameter and assigns its properties to the corresponding fields in the modal. It can also show or hide other modals:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithTrash()\n  -\u003eaddField('name')\n  -\u003eaddField('id')\n  -\u003eshowModal('delete-item-modal') ?\u003e\n\u003c/script\u003e\n```\n\n### withRemove\n\nCreates a `remove` method. This method is used for sending a `DELETE` request to the specified link to remove an item. It takes the item's ID as a parameter, includes it in the request, and shows an alert upon successful deletion before reloading the data:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithRemove()\n  -\u003esetAlert('Item deleted!', 'Item successfully deleted.')\n  -\u003esetLink($url-\u003eset('/v1/items')) ?\u003e\n\u003c/script\u003e\n```\n\n### withClose\n\nCreates a `close` method. This method is used to close modals and reset the values of specified fields. It can also hide other modals and reset fields based on a provided script:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\n// ...\n\n\u003c?= $depot-\u003ewithClose()\n  -\u003ewithScript($script)\n  -\u003ehideModal('delete-item-modal')\n  -\u003ehideModal('item-detail-modal')\n  -\u003eresetField('detail')\n  -\u003eresetField('error')\n  -\u003eresetField('id')\n  -\u003eresetField('name')\n  -\u003eresetField('loadError') ?\u003e\n\u003c/script\u003e\n```\n\nThe `setDefaults` method can also be used for resetting the data with default values:\n\n``` html\n// app/plates/items/depot.php\n\n\u003cscript type=\"text/javascript\"\u003e\n\u003c?= $script = $form-\u003escript('items')\n  -\u003ewith('name')\n  -\u003ewith('detail')\n  -\u003ewith('items', array())\n  -\u003ewith('empty', false)\n  -\u003ewith('loadError', false)\n  -\u003ewith('id', null)\n  -\u003ewith('delete', false)\n  -\u003ewithError()\n  -\u003ewithLoading() ?\u003e\n\n\u003c?= $depot-\u003ewithClose()\n  -\u003esetDefaults($script-\u003egetFields()) ?\u003e\n\n// ...\n\u003c/script\u003e\n```\n\n\u003e [!NOTE]\n\u003e The `Script` class from [Fortem](https://github.com/rougin/fortem) can be used for resetting the data.\n\n## Changelog\n\nPlease see [CHANGELOG][link-changelog] for more recent changes.\n\n## Contributing\n\nSee [CONTRIBUTING][link-contributing] on how to contribute to the project.\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE][link-license] for more information.\n\n[ico-build]: https://img.shields.io/github/actions/workflow/status/rougin/dextra/build.yml?style=flat-square\n[ico-coverage]: https://img.shields.io/codecov/c/github/rougin/dextra?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/rougin/dextra.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-version]: https://img.shields.io/packagist/v/rougin/dextra.svg?style=flat-square\n\n[link-build]: https://github.com/rougin/dextra/actions\n[link-changelog]: https://github.com/rougin/dextra/blob/master/CHANGELOG.md\n[link-contributing]: https://github.com/rougin/dextra/blob/master/CONTRIBUTING.md\n[link-coverage]: https://app.codecov.io/gh/rougin/dextra\n[link-downloads]: https://packagist.org/packages/rougin/dextra\n[link-license]: https://github.com/rougin/dextra/blob/master/LICENSE.md\n[link-packagist]: https://packagist.org/packages/rougin/dextra\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frougin%2Fdextra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frougin%2Fdextra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frougin%2Fdextra/lists"}