Download the PHP package liam-wiltshire/laravel-jit-loader without Composer

On this page you can find all versions of the php package liam-wiltshire/laravel-jit-loader. 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-jit-loader

liam-wiltshire/laravel-jit-loader

liam-wiltshire/laravel-jit-loader is an extension to the default Laravel Eloquent model to 'very lazy eager load' relationships with performance comparable with eager loading.

Installation

liam-wiltshire/laravel-jit-loader is available as a composer package: composer require liam-wiltshire/laravel-jit-loader

Once installed, use the \LiamWiltshire\LaravelJitLoader\Concerns\AutoloadsRelationships trait in your model, or have your models extend the \LiamWiltshire\LaravelJitLoader\Model class instead of the default eloquent model, and JIT loading will be automatically enabled.

Very Lazy Eager Load?

In order to avoid N+1 issues, you'd normally load your required relationships while building your collection:

Or otherwise after the fact, but before use:

In some situations however, this may not be possible - perhaps front-end developers are able to make changes to templates without touching the code, or perhaps during development you know don't which relationships you'll need anyway. This change will track if your models belong to a collection, and if they do and a relationship is called that hasn't already been loaded, the relationship will be loaded across the whole collection just in time for use.

Does This Work?

This is used in a number of production applications with no issues. It's also been tested against a (rather constructed) test, pulling out staff, companies and addresses - while this isn't a 'real life' representation, it should give an idea of what it can do:

Running this locally against a database with 200 companies, 1157 addresses and 39685 staff:

Without JIT Loading:

Queries Run: 10739
Execution Time: 17.090859889984
Memory: 70MiB

With JIT Loading:

Queries Run: 3
Execution Time: 1.7261669635773
Memory: 26MiB

'Proper' Eager Loading:

Queries Run: 3
Execution Time: 1.659285068512
Memory: 26MiB

Logging

As you can see the different between JIT loading and traditional eager loading is small (c. 0.067 seconds in our above test), so you can likely rely on JIT loader to protect you.

However, if you want to log when the JIT loader is used so that you can do back and correct them later, you can add a $logChannel property to your models to ask the trait to log into that channel as configured in Laravel

Limitations

This is an early release based on specific use cases. At the moment the autoloading will only be used when the relationship is loaded like a property e.g. $user->company->name instead of $user->company()->first()->name. I am working on supporting relations loaded in alternate ways, however there is more complexity in that so there isn't a fixed timescale as of yet!

With any eager loading, a sufficiently large collection can cause memory issues. The JIT model specifies a threshold for autoloading. This is set to 6000 by default, but can be changed by overriding the $autoloadThreshold property on a model-by-model basis.


All versions of laravel-jit-loader with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
illuminate/database Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.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 liam-wiltshire/laravel-jit-loader contains the following files

Loading the files please wait ....