PHPackages                             xtend-packages/rest-presenter - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. xtend-packages/rest-presenter

ActiveLibrary[HTTP &amp; Networking](/categories/http)

xtend-packages/rest-presenter
=============================

REST API Presenter &amp; Generator for Laravel

1.1.2(1y ago)771.5k↓100%10[14 issues](https://github.com/xtend-packages/rest-presenter/issues)[1 PRs](https://github.com/xtend-packages/rest-presenter/pulls)MITPHPPHP ^8.2

Since Mar 22Pushed 1y ago2 watchersCompare

[ Source](https://github.com/xtend-packages/rest-presenter)[ Packagist](https://packagist.org/packages/xtend-packages/rest-presenter)[ Docs](https://github.com/xtend-packages/rest-presenter)[ GitHub Sponsors](https://github.com/adam-code-labx)[ RSS](/packages/xtend-packages-rest-presenter/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (24)Versions (57)Used By (0)

  ![RESTPresenter](https://camo.githubusercontent.com/59bed2ea9c5a7f0d9d6d53b2bf807e68fced44a8116d3db4e4ea16e526967c4c/68747470733a2f2f7777772e636f64656c6162782e6c74642f6173736574732f696d616765732f7874656e642d7061636b616765732f726573742d70726573656e7465722f726573742d70726573656e7465722d62616e6e65722d6c696768742e706e67)[![Latest Version on Packagist](https://camo.githubusercontent.com/4af9a4fd794fd597bc9a95f5262012bfd11d1d7a122afbd28a178121d5d41a0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7874656e642d7061636b616765732f726573742d70726573656e7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xtend-packages/rest-presenter)[![PHP from Packagist](https://camo.githubusercontent.com/e397e71c32acbdd060e7d5796f6b1de2e7977a490bca7f0c40125a4c5ac898cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7874656e642d7061636b616765732f726573742d70726573656e746572)](https://packagist.org/packages/xtend-packages/rest-presenter)[![GitHub License](https://camo.githubusercontent.com/df53c803a2dbecc75253a80880d20f38af3eb2f9dd24afe85035d1b8efdfda50/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7874656e642d7061636b616765732f726573742d70726573656e746572)](https://github.com/xtend-packages/rest-presenter/blob/main/LICENSE.md)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b75ac785b4e5dc0f702a9f544d97498ceb209a4a2670c4e8a4a731bffdd1bf24/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7874656e642d7061636b616765732f726573742d70726573656e7465722f74657374732e796d6c3f6c6162656c3d7465737473)](https://github.com/xtend-packages/rest-presenter/actions/workflows/tests.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/da09f135fdffffc2d2ae592a17c74609e44a375d681ea7b67a47172bf07f9d7c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7874656e642d7061636b616765732f726573742d70726573656e7465722f636f64652d7374796c696e672e796d6c3f6c6162656c3d636f64652532307374796c65)](https://github.com/xtend-packages/rest-presenter/actions/workflows/code-styling.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/fa91536f33990eb1ed97002f98595df43fdbfaf79acf5c7b36960d7cd15678fa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7874656e642d7061636b616765732f726573742d70726573656e7465722f7068707374616e2e796d6c3f6c6162656c3d737461746963253230616e616c79736973)](https://github.com/xtend-packages/rest-presenter/actions/workflows/phpstan.yml)[![Total Downloads](https://camo.githubusercontent.com/f2f3bd1b797731e530c12b9ebe2d6ecc9bc9ca69c3e4d949518431bc015a38a8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7874656e642d7061636b616765732f726573742d70726573656e7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xtend-packages/rest-presenter)[![Join our Discord](https://camo.githubusercontent.com/6f4300c239d7f0b743f0c106dbc3565b73096a7ec4c123f95c15954d9ba168ef/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f313033333133383532333538343333313833373f6c6162656c3d446973636f7264266c6f676f3d646973636f7264)](https://discord.gg/j7EAhVVcyX)

Introduction
------------

[](#introduction)

RESTPresenter is a powerful, lightweight package designed to streamline Laravel API development. It integrates seamlessly with Laravel API Resources and Spatie's Data objects, making API creation and management effortless.

With RESTPresenter, you can:

- **Quick API Generation:** Rapidly create comprehensive REST APIs with robust endpoint management and resource handling.
- **Seamless Integration:** Utilize Laravel's API Resources and Spatie's Data objects for streamlined data transformation. Automatically generate TypeScript definitions for ready-to-use, type-safe data structures in front-end frameworks.
- **Filament Plugin Support:** Manage API resources, user tokens, and more through an intuitive Filament plugin.
- **Automated Collections:** Generate Postman and Insomnia collections for easy API testing and documentation.
- **Security and Scalability:** Implement token-based authentication and configure endpoint security settings effortlessly.
- **Comprehensive Testing:** Automatically generate tests for API resources, ensuring data consistency and integrity.
- **Rapid Development Kits:** Use example filters, presenters, and tools for fast API development with extendable resources.

RESTPresenter enhances your Laravel projects with powerful tools for efficient and secure API development.

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

[](#installation)

To get started with RESTPresenter, you need to meet the following requirements:

- PHP ^8.2
- Laravel 10+

Install the package via composer:

```
composer require xtend-packages/rest-presenter
```

Filament Plugin Integration
---------------------------

[](#filament-plugin-integration)

Manage your RESTPresenter resources directly from Filament with our dedicated plugin. This integration allows you to generate user tokens, manage your API resources, and more.

### Plugin Installation

[](#plugin-installation)

To install the RESTPresenter Filament plugin, run:

```
php artisan rest-presenter:filament --install
```

This command will prompt you to auto-commit changes to your Git repository. If you choose not to commit, you can manually commit the changes yourself. The Sanctum StarterKit is automatically installed during this process. For more details, see [Sanctum StarterKit](#sanctum-starter-kit).

### Export API Collection

[](#export-api-collection)

To generate your API collection, run:

```
php artisan rest-presenter:generate-api-collection
```

By default, this command generates a Postman collection. If you prefer Insomnia, switch by setting the following in your `.env` file:

```
REST_PRESENTER_EXPORT_PROVIDER=insomnia
```

For a full list of configuration options, see [Configuration](#configuration).

### Uninstall

[](#uninstall)

To uninstall the RESTPresenter Filament plugin, run:

```
php artisan rest-presenter:filament --uninstall
```

This command will prompt you to auto-commit and revert changes to your Git repository. If you choose not to commit, you can manually commit the changes yourself.

### RESTPresenter Panel

[](#restpresenter-panel)

The new RESTPresenter panel serves as a dashboard, offering a comprehensive overview and management interface for your API collection.

  ![RESTPresenter](https://camo.githubusercontent.com/5e8959683fe41340fb4e3d861caba812770bcb272f37f8c8d7715f1f26319045/68747470733a2f2f7777772e636f64656c6162782e6c74642f6173736574732f696d616765732f7874656e642d7061636b616765732f726573742d70726573656e7465722f726573742d70726573656e7465722d70616e656c2d6c696768742e706e67)You can access the RESTPresenter panel by navigating to `/rest-presenter` in your browser. the path is configurable in the `.env` file see [Configuration](#configuration) for more details.

RESTPresenter panel link has now conveniently been added to the user menu for all your filament panels.

Features include:

- **API Endpoints:** View all your API endpoints in one place, especially useful when you update a resource to require authentication.
- **Token Generation:** Generate user tokens for secure API access. You can define the token name, abilities, and expiration datetime. Simply copy the generated token to your API client to use with any authenticated endpoints.
- **Users Resource:** Detailed view of user tokens. From here, you can revoke tokens.

> **Coming Soon:** Test Coverage and Reports, just one of many features in active development.

### Endpoint Authentication &amp; Security

[](#endpoint-authentication--security)

By default, all endpoints are publicly available without Sanctum middleware, protected by a security API key which you can update via `REST_PRESENTER_AUTH_API_KEY` in your `.env` file.

You can make any endpoint authenticated by updating the `isAuthenticated` property in the resource controller. This will automatically add the Sanctum middleware to the endpoint.

```
