PHPackages                             rougin/dextra - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rougin/dextra

ActiveLibrary[API Development](/categories/api)

rougin/dextra
=============

"Ready-to-eat" CRUD for frontend.

0326PHPCI passing

Since Nov 20Pushed 5mo agoCompare

[ Source](https://github.com/rougin/dextra)[ Packagist](https://packagist.org/packages/rougin/dextra)[ RSS](/packages/rougin-dextra/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Dextra
======

[](#dextra)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5b91c2e6079beb602c26c19b83d9777da668dff77aa5f1e08b2eed68d7817e0c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f7567696e2f6465787472612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rougin/dextra)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/rougin/dextra/blob/master/LICENSE.md)[![Build Status](https://camo.githubusercontent.com/e62e28e5d06f8f149ba122148e3f362cd62701d06bbde5dd22822ce9952c0771/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f7567696e2f6465787472612f6275696c642e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/rougin/dextra/actions)[![Coverage Status](https://camo.githubusercontent.com/f6042cb7ffe66027ddf8cc455e44a3598491f325414044dd97639e4a032a4607/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f726f7567696e2f6465787472613f7374796c653d666c61742d737175617265)](https://app.codecov.io/gh/rougin/dextra)[![Total Downloads](https://camo.githubusercontent.com/73294b4fec8f37a45b69b1899ee2c26f4f4feee781db250cb4f99d6663aea0a8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f7567696e2f6465787472612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rougin/dextra)

`Dextra` is a PHP utility package that provides templates based on [alpine.js](https://alpinejs.dev/) for handling frontend CRUD.

Installation
------------

[](#installation)

Install the package using [Composer](https://getcomposer.org/):

```
$ composer require rougin/dextra
```

Basic usage
-----------

[](#basic-usage)

Use the `Depot` class to initialize the CRUD methods:

```
// app/plates/items/depot.php

// ...

```

Then use the available methods below once defined:

### withInit

[](#withinit)

Creates 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:

```
// app/plates/items/depot.php

// ...

withInit(1) ?>

```

### withLoad

[](#withload)

Creates 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`):

```
// app/plates/items/depot.php

// ...

withLoad(10)
  ->setLink($url->set('/v1/items')) ?>

```

It 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`:

```
// app/plates/items/depot.php

// ...

withLoad(10)
  ->setPageKey('p')
  ->setLimitKey('l')
  ->setLink($url->set('/v1/items')) ?>

```

### withStore

[](#withstore)

Creates 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:

```
// app/plates/items/depot.php

// ...

withStore()
  ->addField('name')
  ->addField('detail')
  ->setAlert('Item created!', 'Item successfully created.')
  ->setLink($url->set('/v1/items')) ?>

```

### withEdit

[](#withedit)

Creates 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:

```
// app/plates/items/depot.php

// ...

withEdit()
  ->addField('name')
  ->addField('detail')
  ->addField('id')
  ->showModal('item-detail-modal') ?>

```

### withUpdate

[](#withupdate)

Creates 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:

```
// app/plates/items/depot.php

// ...

withUpdate()
  ->addField('name')
  ->addField('detail')
  ->setAlert('Item updated!', 'Item successfully updated.')
  ->setLink($url->set('/v1/items')) ?>

```

### withTrash

[](#withtrash)

Creates 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:

```
// app/plates/items/depot.php

// ...

withTrash()
  ->addField('name')
  ->addField('id')
  ->showModal('delete-item-modal') ?>

```

### withRemove

[](#withremove)

Creates 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:

```
// app/plates/items/depot.php

// ...

withRemove()
  ->setAlert('Item deleted!', 'Item successfully deleted.')
  ->setLink($url->set('/v1/items')) ?>

```

### withClose

[](#withclose)

Creates 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:

```
// app/plates/items/depot.php

// ...

withClose()
  ->withScript($script)
  ->hideModal('delete-item-modal')
  ->hideModal('item-detail-modal')
  ->resetField('detail')
  ->resetField('error')
  ->resetField('id')
  ->resetField('name')
  ->resetField('loadError') ?>

```

The `setDefaults` method can also be used for resetting the data with default values:

```
// app/plates/items/depot.php

script('items')
  ->with('name')
  ->with('detail')
  ->with('items', array())
  ->with('empty', false)
  ->with('loadError', false)
  ->with('id', null)
  ->with('delete', false)
  ->withError()
  ->withLoading() ?>

withClose()
  ->setDefaults($script->getFields()) ?>

// ...

```

Note

The `Script` class from [Fortem](https://github.com/rougin/fortem) can be used for resetting the data.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://github.com/rougin/dextra/blob/master/CHANGELOG.md) for more recent changes.

Contributing
------------

[](#contributing)

See [CONTRIBUTING](https://github.com/rougin/dextra/blob/master/CONTRIBUTING.md) on how to contribute to the project.

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](https://github.com/rougin/dextra/blob/master/LICENSE.md) for more information.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance48

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7721589a958a1fbcef1b527c794d820d75b82988f14b2ed86a1c6904d76a59e?d=identicon)[rougin](/maintainers/rougin)

---

Top Contributors

[![rougin](https://avatars.githubusercontent.com/u/6078637?v=4)](https://github.com/rougin "rougin (18 commits)")

---

Tags

php-crudphp-uiui-template

### Embed Badge

![Health badge](/badges/rougin-dextra/health.svg)

```
[![Health](https://phpackages.com/badges/rougin-dextra/health.svg)](https://phpackages.com/packages/rougin-dextra)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
