PHPackages                             macropay-solutions/php-crufd-wizard-decorator - 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. [Admin Panels](/categories/admin)
4. /
5. macropay-solutions/php-crufd-wizard-decorator

ActiveLibrary[Admin Panels](/categories/admin)

macropay-solutions/php-crufd-wizard-decorator
=============================================

Data composition/decoration for php-crufd-wizard library including url query language

1.0.0-RC-3(1mo ago)2211MITPHPPHP ^8.2CI passing

Since Jun 28Pushed 1mo agoCompare

[ Source](https://github.com/macropay-solutions/php-crufd-wizard-decorator)[ Packagist](https://packagist.org/packages/macropay-solutions/php-crufd-wizard-decorator)[ RSS](/packages/macropay-solutions-php-crufd-wizard-decorator/feed)WikiDiscussions production Synced 2w ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (1)

php-crufd-wizard-decorator - RetrieveQL
=======================================

[](#php-crufd-wizard-decorator---retrieveql)

[![Build Status](https://github.com/macropay-solutions/php-crufd-wizard-decorator/actions/workflows/tests.yml/badge.svg)](https://github.com/macropay-solutions/php-crufd-wizard-decorator/actions)[![Total Downloads](https://camo.githubusercontent.com/5001efffcf9b7614aa9e033d9e077e9cb581d7c25ee11fe7a881a222a44b536b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6163726f7061792d736f6c7574696f6e732f7068702d63727566642d77697a6172642d6465636f7261746f72)](https://packagist.org/packages/macropay-solutions/php-crufd-wizard-decorator)[![Latest Stable Version](https://camo.githubusercontent.com/e3f9862d871796706d9854963534db4d57e6e05ea84d9296026809736617f1b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6163726f7061792d736f6c7574696f6e732f7068702d63727566642d77697a6172642d6465636f7261746f72)](https://packagist.org/packages/macropay-solutions/php-crufd-wizard-decorator)[![License](https://camo.githubusercontent.com/7d552a5f564e62dd5a6f39dde103be8fc7267e46b73874ec2c995be6e9370072/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6163726f7061792d736f6c7574696f6e732f7068702d63727566642d77697a6172642d6465636f7261746f72)](https://packagist.org/packages/macropay-solutions/php-crufd-wizard-decorator)

This can be used for decorating [php-crufd-wizard](https://github.com/macropay-solutions/php-crufd-wizard)

Decorator High Level Comparison: Freemium vs Pro
------------------------------------------------

[](#decorator-high-level-comparison-freemium-vs-pro)

The Decorator suite acts as the presentation layer for your microservices, bridging the gap between your internal database structure and your public API contract.

FeatureDecorator Freemium (`php-crufd-wizard-decorator`)Decorator Pro (`php-rest-wizard-decorator`)**Schema Masking**✅ Rename/Map resource &amp; relation columns✅ Rename/Map resource &amp; relation columns**Relation Wrapping**✅ Decorate attributes of loaded relations✅ Decorate attributes of loaded relations**Data Flattening**✅ **Single Table Flattening** (Merge resource + relations into one flat response)✅ **Single Table Flattening** (Merge resource + relations into one flat response)**Virtual Columns**❌✅ **Composed Columns** (Create new fields from multiple resource/relation columns)**Memory-Safe Export**❌✅ **Streamed CSV Download** (Direct to client; no file saved on server)**Filter Transformation**❌✅ **Query Rewriting** (Map resource columns to relation filters via URL query string)**Response Control**✅ Standard JSON decoration✅ **Restricted Columns** (Return only requested keys, including in CSV streams)**Relational Updates**❌✅ **One-to-One Update** (Update related models during resource update)**Aggregations**❌✅ **Resource &amp; Relation Aggregations** (Sums, Avgs, etc. on children) from php-rest-wizard**Security (XSS)**✅ **Auto-Sanitization** (All JSON string values parsed by `htmlspecialchars`)✅ **Auto-Sanitization** (All JSON string values parsed by `htmlspecialchars`)---

### Key Advantages of the Pro Decorator Suite

[](#key-advantages-of-the-pro-decorator-suite)

#### Zero-Footprint CSV Streaming

[](#zero-footprint-csv-streaming)

The Pro decorator can stream millions of rows directly to the client's browser without ever saving a temporary file on the server. This bypasses PHP `memory_limit` crashes and eliminates "Disk Full" errors during large exports.

#### Composed &amp; Flattened Data

[](#composed--flattened-data)

Build high-performance frontend tables with ease. Pro allows you to merge data from multiple relations and compose new virtual columns (e.g., calculating `margin` from `cost` and `price` fields across different tables) on the fly.

#### Relation Filter Transformation

[](#relation-filter-transformation)

Eases the complexity of URL queries. Users can filter by a "public" mapped column name, and the engine automatically transforms it into the correct internal relational logic (joins/where clauses) behind the scenes.

#### Atomic One-to-One Updates

[](#atomic-one-to-one-updates)

Maintain data integrity without extra controller boilerplate. When you update a main resource, the Pro decorator handles the simultaneous update of any associated one-to-one relations in a single, clean operation.

### AI Integration Note

[](#ai-integration-note)

If you are using the PHP Framework `.cursorrules` configuration, use the `{--decorated}` flag with the generator:

```
php run make:api-resource {resourceName} --decorated
```

It renames/maps the column names for the resource and its relations.

The reserved words / parameters that will be used as query params are:

- perPage
- page

The `withRelations, withRelationsCount, withRelationsExistence` query params will be disregarded

I. [Install](#i-install)

II. [Start using it](#ii-start-using-it)

III. [Crud routes](#iii-crud-routes)

III.1. [Create resource](#iii1-create-resource)

III.2. [Get resource](#iii2-get-resource)

III.3. [List filtered resource](#iii3-list-filtered-resource)

III.4. [Update resource (or create)](#iii4-update-resource-or-create)

III.5. [Delete resource](#iii5-delete-resource)

I. Install
----------

[](#i-install)

```
composer require macropay-solutions/php-crufd-wizard-decorator

```

II. Start using it
------------------

[](#ii-start-using-it)

OBS.

- The `withRelations, withRelationsCount, withRelationsExistence` query params will be disregarded. These are to be used only internally with undecorated request.
- 202 http response code will not be decorated, and it can be used to send messaged to FE. Example: {"message":"Accepted"}
- 204 http response will be decorated as empty body.

Use the middleware in your crud route definition for each method if you have only few routes (it is faster to use the middleware FQN directly in the route definition):

```
    SomeMiddleware::class . ':list'
    SomeMiddleware::class . ':get'
    SomeMiddleware::class . ':getRelated'
    SomeMiddleware::class . ':update'
    SomeMiddleware::class . ':updateRelated'
    SomeMiddleware::class . ':create'
    SomeMiddleware::class . ':delete'
    SomeMiddleware::class . ':deleteRelated'
```

In this way you avoid loading on each request the route middleware array that in some cases can become quite big (hundreds of elements).

Coupled with cached routes this solution is faster than the initial one.

Example:

```
