Download the PHP package daltonmccleery/remote-models without Composer

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

Remote Models

Sometimes you want to use Eloquent, but that data is in another database on a different application.

This package is used for both the "host" application and the "remote" application. Both use cases are detailed below, or you can look at these examples.

Requirements

The pdo-sqlite PHP extension must be installed on your system to use this package.

You will need to set up any endpoints on the host application where the data is stored.

Install

Publishing the Config

It is recommended to publish the config file; this will allow you to add a host domain, API pathing, and any Models.

Remote Use

Using this package consists of two steps:

  1. Add the RemoteModel trait to a model.

That's it.

Now, you can use this model anywhere you like, and it will behave as if the table exists in your application.

This will allow you to add a host domain, API pathing, and any Models.

Custom Endpoint

You may provide a custom endpoint to your Remote Model that will be called when the model is loaded. If you do this and have this package installed on your host application, you will need to create your own API endpoint.

Custom Schema

Remote Models will auto-discover the schema from the first API call, however, if you want more control over the schema or what fields are saved locally, you may add them to a $schema property with a type cast for the column.

Host Use

This package is dependent on a separate Laravel application that "hosts" the Models and their data. You will need to either install this package on the host application as well and enter the "remote" models you wish to expose to the "remote" application.

Custom Endpoint

If you use a custom endpoint on the remote application, you will need to set up that custom route. You can use the following as an example:

If you do not install this package on the "host" application, a custom endpoint will need to be set up for each Remote Model you plan on using. You will also need to manually validate the given API Key. You can use the following as an example:

You are not required to install this package on the "host" application. If you don't, you will need to set up your own API endpoints for the models you wish to use. It is recommended to use Laravel's default pagination.

Cache Interval

You can set how long to cache the remote data for using the cache-ttl config option. These values follow the standard [DateTime Interval](https://www.php.net/manual/en/class.dateinterval.php properties. Below are a few examples:

External Host Data

There may be instances where you do not control the "host" application, i.e. it could be a Google Spreadsheet or a 3rd party API, but would still like a way to query that data using Eloquent.

You'll need to have your Model implement the RemoteModelInterface and include the base RemoteModelManagement trait. This will have you implement 2 methods for setting up a custom schema (optional) and recursively fetching the data. In this instance, the $remoteEndpoint is optional.

You can create your own Remote Model by following this example:

How It Works

When a Model is called, it will make an API call to the either a custom endpoint or to a predefined endpoint using the Model's name. This predefined API endpoint can be configured in the config file.

Under the hood, this package creates and caches a SQLite database just for this model and all its data. It creates a table and populates it with the returned, paginated API data. If, for whatever reason, it can't cache a .sqlite file, it will default to using an in-memory sqlite database.

This package was heavily inspired by Caleb Porzio's Sushi package.

Upcoming Features


All versions of remote-models with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-pdo_sqlite Version *
ext-sqlite3 Version *
guzzlehttp/guzzle Version ^7.8
illuminate/database Version ^10.0 || ^11.0
illuminate/support Version ^10.0 || ^11.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 daltonmccleery/remote-models contains the following files

Loading the files please wait ....