Download the PHP package hds-solutions/laravel-api-helpers without Composer

On this page you can find all versions of the php package hds-solutions/laravel-api-helpers. 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 laravel-api-helpers

Laravel API Helpers

This library simplifies the process of building API controllers by providing convenient classes for managing filtering, ordering, relationship loading, and pagination of resource collections.

Latest stable version License Total Downloads Monthly Downloads Required PHP version

Features

Installation

Dependencies

Via composer

Usage

To make use of the library, you will need to create specific classes that extend the provided abstract classes. The provided classes contain the implementation of the necessary logic for each feature (filtering, sorting, relationship loading, and pagination).

ResourceFilters

The ResourceFilters class manages the query filters for resource collections. It allows you to define the allowed columns and their corresponding filter operators.

In the extended class, you can define the list of allowed columns that can be used for filtering, along with their allowed operators.

The available operators are:

Operators are also grouped by field type:

Example implementation

You just need to extend the ResourceFilters class and define the allowed filtrable columns.

You can also override the default filtering implementation of a column by defining a method with the same name as the filtrable column. The method must have the following arguments:

Example requests

ResourceOrders

The ResourceOrders class manages the sorting of resource collections. It allows you to define the allowed columns to sort the resource collection and a default sorting fields.

In the extended class, you can define the list of allowed columns that can be used for sorting the resource collection.

Example implementation

You just need to extend the ResourceOrders class and define the allowed sortable columns.

You can also override the default sorting implementation of a column by defining a method with the studly version of the sortable column. The method must have the following arguments:

Example requests

The request sorting parameters must follow the following syntax: order[{index}][{direction}]={field}

ResourceRelations

The ResourceRelations class manages the loading of extra relationships for resource collections. It allows you to specify the allowed relationships to be loaded and the relationships that should always be loaded.

In the extended class, you can define the list of allowed relationships that can be added to the resource collection.

Example implementation

You can also capture the loaded relationship to add filters, sorting, or any action that you need. The method must have the following arguments:

Example requests

PaginateResults

The PaginateResults class handles the pagination of resource collections. It provides support for paginating the results or retrieving all records.

Example requests

Controller implementation

Here is an example of a controller using the Pipeline facade to implement all the previous features.

More request examples

Example response:

Example response:

Example response:

Extras

Before and after callbacks

The ResourceFilters and ResourceOrders classes have two methods (before & after) that allow a better customization on the query builder. You can override them to make more manipulations to the query builder.

ResourceRequest

The ResourceRequest class has the following features:

Caching requests

You can use the hash() method of the ResourceRequest class and use it as a cache key. The parameter cache is ignored and not used to build the request identifier.

In the following example, we capture the cache request parameter to force the cache to be cleared.

Security Vulnerabilities

If you encounter any security-related issues, please feel free to raise a ticket on the issue tracker.

Contributing

Contributions are welcome! If you find any issues or would like to add new features or improvements, please feel free to submit a pull request.

Contributors

Licence

This library is open-source software licensed under the MIT License. Please see the License File for more information.


All versions of laravel-api-helpers with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1|^8.2|^8.3|^8.4
laravel/framework Version ^9.0|^10.0|^11.0|^12.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 hds-solutions/laravel-api-helpers contains the following files

Loading the files please wait ....