PHPackages                             psx/api-laravel - 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. psx/api-laravel

ActiveLibrary[API Development](/categories/api)

psx/api-laravel
===============

Laravel package to build type-safe APIs

16PHP

Since Oct 3Pushed 7mo agoCompare

[ Source](https://github.com/apioo/psx-api-laravel)[ Packagist](https://packagist.org/packages/psx/api-laravel)[ RSS](/packages/psx-api-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PSX API Package
===============

[](#psx-api-package)

> Note the Laravel integration is currently work in progress. In the package we use custom [Contextual Attributes](https://laravel.com/docs/12.x/container#contextual-attributes) but at the moment it is not possible to access the `ReflectionParameter` inside the resolver, which we need to get the type-hint. We have tried to create a [Pull-Request](https://github.com/laravel/framework/pull/57129) but for now this is not solved.

The PSX API package integrates the [PSX API components](https://phpsx.org/) into Laravel which help to build fully type-safe REST APIs. Basically the package provides additional attributes which you can use at your [controller](#controller) to map HTTP parameters to arguments of your controller and commands to generate based on those attributes and type-hints different artifacts:

- Generate Client SDKs for different languages i.e. TypeScript and PHP
    - `php artisan generate:sdk client-typescript`
- Generate OpenAPI specification without additional attributes
    - `php artisan generate:sdk spec-openapi`
- Generate DTO classes using [TypeSchema](https://typeschema.org/)
    - `php artisan generate:model`

As you note this bundle is about REST APIs and not related to any PlayStation content, the name PSX was invented way back and is simply an acronym which stands for "**P**HP, **S**QL, **X**ML"

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

[](#installation)

To install the bundle simply require the composer package at your Laravel project.

```
composer require psx/api-laravel

```

Make sure, that the package is registered at the `bootstrap/providers.php` file:

```
return [
    PSX\ApiLaravel\ApiServiceProvider::class,
];
```

Controller
----------

[](#controller)

The following is a simple controller which shows how to use the PSX specific attributes to describe different HTTP parameters:

```
