Download the PHP package iafilin/eloquenthttpadapter without Composer

On this page you can find all versions of the php package iafilin/eloquenthttpadapter. 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 eloquenthttpadapter

EloquentHttpAdapter

EloquentHttpAdapter is a Laravel package that provides an alternative to calebporzio/sushi. It allows you to work with RESTful API data using an Eloquent-like syntax.

This package was originally developed to integrate Filament with APIs, making it a convenient tool for admin panels. However, thanks to its flexibility, it can also be used for any task requiring API integration with an Eloquent-like interface.


Installation

Install the package via Composer:


Usage

Setting Up a Model

To enable API integration, use the InteractsWithHttp trait and define a custom httpClient method to configure the HTTP client:


Registering a Fetch Parameters Resolver

You can define the logic for building HTTP query parameters using the registerFetchParamsResolver method. This allows dynamic configuration of pagination, filtering, and sorting parameters.

Additionally, within the resolver, you have access to the getQuery() object, which lets you retrieve Eloquent wheres conditions and use them to generate HTTP parameters.

Example setup:


API Requirements

To ensure compatibility with the package, your API should follow these conventions:

  1. Standard REST endpoints:

    • POST /api/resource — Create records.
    • GET /api/resource — Fetch records (paginated or full list).
    • GET /api/resource/{id} — Fetch a single record.
    • PUT /api/resource/{id} — Update a record.
    • DELETE /api/resource/{id} — Delete a record.
  2. Response Structure:
    • Lists: Should include data, total, per_page, and current_page.
    • Single Record: Should return attributes directly without nesting.

Example paginated response:

  1. Pagination:

    • Support for page and per_page query parameters.
  2. Filters and Sorting:
    • Filters: filter[column]=value.
    • Sorting: sort=column for ascending and sort=-column for descending.

CRUD Operations

Once your model is set up, you can use standard Eloquent methods to interact with your API:

Create a Record

Read Records

Update a Record

Delete a Record


Customizing HTTP Requests

You can fully customize HTTP request behavior by overriding the httpClient method in your model. For example, adding headers or specific configurations:


If you have any questions or suggestions, feel free to open an issue or contribute! 💡


Customizing API Fetch Parameters with registerFetchParamsResolver

The registerFetchParamsResolver method allows you to customize the HTTP query parameters sent to your API for fetching data. It provides a powerful way to dynamically build parameters like pagination, filters, and sorting based on the current Eloquent query or incoming user requests.

With access to the Eloquent query object ($this->getQuery()), you can parse wheres, orders, and other query conditions, transforming them into HTTP parameters compatible with your API.

Key Benefits:

Example Usage:

This makes it easy to dynamically adapt HTTP query parameters based on user input or predefined conditions in your Laravel application.

Error Handling

The package automatically logs errors during API interactions and returns null in case of failure. This ensures graceful handling of API downtime or errors without throwing exceptions.


License

This package is open-source and licensed under the MIT license.


All versions of eloquenthttpadapter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0
illuminate/database 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 iafilin/eloquenthttpadapter contains the following files

Loading the files please wait ....