Download the PHP package psx/api-bundle without Composer

On this page you can find all versions of the php package psx/api-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package api-bundle

PSX API Bundle

The PSX API bundle integrates the PSX API components into Symfony which help to build fully type-safe REST APIs. Basically the bundle provides additional attributes which you can use at your controller to map HTTP parameters to arguments of your controller and commands to generate based on those attributes and type-hints different artifacts:

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 "PHP, SQL, XML"

Installation

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

Make sure, that the bundle is registered at the config/bundles.php file:

Controller

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

In the example we use the #[Query], #[Param] and #[Body] attribute to map different parts of the incoming HTTP request. In the controller we use a fictional PostService and PostRepository but you are complete free to design the controller how you like, for PSX it is only important to map the incoming HTTP request parameters to arguments and to provide a return type.

Raw payload

We always recommend to generate concrete DTOs to describe the request and response payloads. If you need a raw payload we provide the following type-hints to receive a raw value.

For example to write a simple proxy method which returns the provided JSON payload s.

Multiple response types

In case your method can return different response types you can use the #[Outgoing] attribute to define a response schema independent of the return type.

Generator

SDK

To generate an SDK you can simply run the following command:

This reads alls the attributes from your controller and writes the SDK to the output folder. At first argument you can also provide a type, by default this is client-typescript but you can also select a different type.

SDKgen

Through the SDKgen project you have the option to generate also client SDKs for different programming languages, therefor you only need to register at the SDKgen website to obtain a client id and secret which you need to set as psx_api.sdkgen_client_id and psx_api.sdkgen_client_secret at your config. After this you can use one of the following types:

TypeHub

If you want to share your API specification it is possible to push your specification to the TypeHub platform with the following command:

Then you also need to provide a client id and secret for your account. The TypeHub platform basically tracks all changes of the API specification and it is possible to download different SDKs.

Model

This bundle also provides a model generator which helps to generate DTOs to describe the incoming and outgoing payload s.

This commands reads the TypeSchema specification located at config/typeschema.json and writes all model classes to src/Model. In general TypeSchema is a JSON specification to describe data models. The following is an example specification to generate a simple Student model.

Configuration

The bundle needs the following psx_api.yaml configuration:

The base_url is the absolute url to your API so that you don't need to provide the base url at your client SDK.

The sdkgen_client_id and sdkgen_client_secret are credentials to the SDKgen app.

Technical

This bundle tries to not change any Symfony behaviour, for example we use the existing #[Route] attribute instead of the #[Path] attribute. This has some small tradeoffs, at first you are required to use the #[Route] attribute, YAML, XML or PHP routing is not supported, since otherwise the generate command will not be able to parse the routes, and second your route has to specify a concrete HTTP method filter, since the SDK generator needs a concrete HTTP method for every endpoint.

Basically the bundle only registers the following classes:

Community

Feel free to create an issue or PR in case you want to improve this bundle. We also like to give a shout-out to praswicaksono for implementing a first version of this bundle.


All versions of api-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
psx/api Version ^7.2
psx/data Version ^7.0
psx/schema Version ^7.2
psx/sql Version ^4.1
symfony/framework-bundle Version ^6.4|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package psx/api-bundle contains the following files

Loading the files please wait ....