Download the PHP package robertogallea/eloquent-api without Composer

On this page you can find all versions of the php package robertogallea/eloquent-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 eloquent-api

Eloquent Models for json APIs

A package that lets you lay Eloquent on top of a json web API.

This package provides an Eloquent model that sits on top of a json web API endpoint.

When you use this package, an initial invocation of the model will make one or more requests to an HTTP endpoint, data are read and converted in an array of rows. Each row is stored as a record in a table inside a file-based sqlite database. Subsequent invocations of the model use that sqlite database so changes underlying data won't be reflected in the database. However, there are two ways that you can invalidate the sqlite cache and cause it to be recreated:

  1. You can call the invalidateCache() method on the model with something like YourApiModel::first()->invalidateCache()

  2. By sending a request to a route provided by this package that deletes the sqlite database forcing a fresh load the next time the model is used.

Installation

Usage

Consider the following JSON response, provided by the endpoint https://ghibliapi.herokuapp.com/films

We want to lay an Eloquent model on top of it.

Step 1 - Enter the full path to the directory where you want to create the model file (defaults to app_path()):


Step 2 - Enter the name you want to use for your model class:


Step 3 - Paste the endpoint of your resource:


Step 4 - If your data is wrapped in a particular field, type its name:


Step 5 - If your resource is paginated, type the json field containing the url of the next page:


Step 6 - Confirm that the path and full classname look right:

The Resulting Model Class

Dealing with wrapped resources

If your resource data is wrapped into a particular json key, you need to tell your model, what this key is, by setting the $dataField model attribute. For example

Dealing with paginated data

If your endpoint provides paginated data, the package support multiple page fetching. In this case all you need to do, is setting the $nextPageField attribute as a string containing the name of the json field containing the next page link, for example

This model can do your basic Eloquent model stuff because it really is an Eloquent model. Though it's currently limited to read / list methods. Update and insert don't currently work.

Issues, Questions and Pull Requests

You can report issues and ask questions in the issues section. Please start your issue with ISSUE: and your question with QUESTION:

If you have a question, check the closed issues first. Over time, I've been able to answer quite a few.

To submit a Pull Request, please fork this repository, create a new branch and commit your new/updated code in there. Then open a Pull Request from your new branch. Refer to this guide for more info.


All versions of eloquent-api with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^7.4|^8
calebporzio/sushi Version ^2.0
guzzlehttp/guzzle Version ^6.5|^7
ext-json Version *
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 robertogallea/eloquent-api contains the following files

Loading the files please wait ....