Download the PHP package mediagone/symfony-easy-api without Composer

On this page you can find all versions of the php package mediagone/symfony-easy-api. 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 symfony-easy-api

Symfony EasyAPI

Latest Version on Packagist Total Downloads

This package provides helper classes to build a Json API very easily from plain Symfony controllers. \ Supported features :

Installation

This package requires PHP 7.4+.

Add it as Composer dependency:

Introduction

This package provides several classes to handle API requests and return structured JSON responses:

Examples

The easiest way to build an API controller is to use the EasyApi class and wrap the controller code in an anonymous function, to benefit from automatic error handling.

1. Entity instance API endpoint

The EasyApi->response method accepts any callable argument that returns an ApiPayload instance.

In case of success, the previous controller will return the following JSON object:

Or a "not found" response:

Or a "server error" response:

Note: errorCode is the internal error's code of the PHP exception (0 by default). You can generally define it by passing an additional integer argument to the constructor, eg. throw new LogicException("Invalid\$thingIdvalue ($thingId)", 1234);.

2. Entity collection API endpoint

You can also return multiple results by using the ApiPayload200Success::createWithArrayResult factory method:

It will result in a slightly different JSON object:

3. Collection pagination

When dealing with a lot of database entries, you may want to paginate results to retrieve them chunk by chunk. \ The package provides the ApiPagination class to help with that feature.

It requires two database queries: one to count the total number of results, and another to fetch the requested results:

Assuming that you have 93 rows in your database and you are requesting the 2nd page of 5 results, you'll receive the following JSON response:

License

Symfony EasyAPI is licensed under MIT license. See LICENSE file.


All versions of symfony-easy-api with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
ext-json Version *
symfony/http-foundation Version ^4.0|^5.0|^6.0|^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 mediagone/symfony-easy-api contains the following files

Loading the files please wait ....