Download the PHP package longman/laravel-lodash without Composer

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

Laravel Lodash

Build Status Latest Stable Version Total Downloads Downloads Month

This package adds lot of useful functionality to the Laravel >=13.0 project.

Compatibility

The package major does not track the Laravel major. It did for some releases (lodash 11 targets Laravel 11, lodash 13 targets Laravel 13), but a package major is cut for this package's own breaking changes, so lodash 14 through 16 all target Laravel 13. Read the table rather than inferring from the version number.

laravel-lodash Laravel framework PHP
^16.0 ^13.0 ^8.4
^15.0 ^13.0 ^8.4
^14.0 ^13.0 ^8.4
^13.0 ^13.0 ^8.4
^12.0 ^11.0 or ^12.0 ^8.2 or ^8.4
^11.0 ^11.0 ^8.2
^10.0 ^10.0 ^8.2
^9.0 ^10.0 ^8.1
^8.0 ^8.0 or ^9.0 ^8.1
^7.0 ^9.0 ^8.1
^6.0 ^8.0 ^8.0
^5.0 ^8.0 ^8.0
^4.0 ^8.0 ^7.4
^3.0 ^7.3 ^7.3
^2.0 ^6.3 ^7.2
^1.0 5.5 to 5.8 >=7.1.3

The 12.x line moved framework support mid-major: 12.0 targets Laravel 11, 12.1 accepts Laravel 11 or 12, and 12.2 requires Laravel 12 and PHP 8.4. Prefer ^12.2 when targeting Laravel 12.

If your application is still on an older Laravel major, install the matching tag of laravel-lodash from the table above.

Table of Contents

Installation

Install this package through Composer.

Run a command in your command line:

composer require longman/laravel-lodash

Longman\LaravelLodash\ServiceProvider is registered automatically through Laravel's package discovery, so there is no provider to add by hand.

The opt-in feature providers are a separate matter. Cache, Redis, Queue, Elasticsearch and Debug are deliberately not auto-discovered, because each one replaces or extends a Laravel provider. Register those explicitly, as documented in the feature section that covers each.

Copy the package config and translations to your application with the publish command:

php artisan vendor:publish --provider="Longman\LaravelLodash\ServiceProvider"

Usage

General

Enable Debug Mode depending on visitor's IP Address

Add Longman\LaravelLodash\Debug\DebugServiceProvider::class in to config/app.php and specify debug IP's in your config/lodash.php config file:

Add created_by, updated_by and deleted_by to the eloquent models

Sometimes we need to know who created, updated or deleted entry in the database.

For this just add Longman\LaravelLodash\Eloquent\UserIdentities trait to your model and also update migration file adding necessary columns:

Use UUID in the Eloquent Models

For this just add Longman\LaravelLodash\Eloquent\UuidAsPrimary trait to your model and also update related migration file:

Also there is possible to specify uuid version via defining uuidVersion property in the model class.

Eager loading of limited many to many relations via subquery or union

Eager load many to many relations with limit via subquery or union. For using this feature, add Longman\LaravelLodash\Eloquent\ManyToManyPreload trait to the models. After that you can use methods limitPerGroupViaUnion() and limitPerGroupViaSubQuery(). For example you want to select users and 3 related user photos per user.

Now each user model have 3 photos model selected via one query. You can specify additional where clauses or order by fields before the group method call.

Redis using igbinary

Igbinary is a drop in replacement for the standard php serializer. Igbinary stores php data structures in compact binary form. Savings are significant when using Redis or similar memory based storages for serialized data. Via Igbinary repetitive strings are stored only once. Collections of Eloquent objects benefit significantly from this.

By default Laravel does not provide an option to enable igbinary serializer for PhpRedis connection and you have to use LaravelLodash implementation for this.

First of all, make sure you enabled PhpRedis driver by this guide https://laravel.com/docs/5.5/redis#phpredis

After that include Cache and Redis service providers in the app.php before your App providers:

You can remove Laravel's Cache and Redis service providers from the config, because LaravelLodash providers are extended from them and therefore implements entire functional.

Now you can specify the serializer in your database.php under config folder:

Also, you can specify other options like scan or etc. See https://github.com/phpredis/phpredis#setoption

Redis client side sharding

PhpRedis extension along with native Redis Cluster, also supports client-side sharding. This feature is very useful, when you want distribute your data between multiple servers, but do not want use native Redis Cluster.

Its not implemented in the Laravel by default. We tried to fix this :smile:

Config example:

AWS SQS Fifo Queue

Laravel by default does not supports AWS FIFO queues and this package fixes it.

You have to add QueueServiceProvider service provider in the app.php before your App providers:

You can remove Laravel's Queue service provider from the config, because LaravelLodash provider are extended from that and therefore implements entire functional.

Now you can add the new connection in the queue.php under config folder:

Elasticsearch Integration

First of all you have to install official elasticsearch php sdk:

composer require elasticsearch/elasticsearch

After add ElasticsearchServiceProvider service provider in the app.php before your App providers:

Now you can add the configuration in the services.php under config folder:

You can use Elasticsearch integration via

Also you can perform search via searchable query object. Just create class and implement ElasticsearchQueryContract and you can pass object to performSearch method

Check if installed packages are in sync with composer.lock

For development purposes, it is recommended to check if vendor folder is in sync with composer.lock file.

For this, in composer.json you have to add script ComposerScripts::createPackageHash:

And in the AppServiceProvider::boot add these lines:

Helper Functions

Function Description
p(...$values): void Add debug messages to the debugbar
get_db_query(): ?string Get last executed database query
get_db_queries(): ?array Get all executed database queries

Extended Classes

The service provider is auto-discovered, but these macros are off by default. Publish the config and set register.request_macros to true in config/lodash.php to enable them.

There is an extended classes via Laravel's builtin macros functionality

Request class

Method Description
getInt(string $name, int $default = 0): int Return request field value as a integer
getBool(string $name, bool $default = false): bool Return request field value as a boolean
getFloat(string $name, float $default = 0): float Return request field value as a float
getString(string $name, string $default = ''): string Return request field value as a string

API Resources and Relationships

Longman\LaravelLodash\Http\Resources\JsonResource exposes each relationship as an include<Name>() method and renders only the relationships the client requested.

A populated relationship carries its own data wrapper, one level deeper than the relationship key:

A requested relationship that resolves to nothing renders as null at the relationship key itself, one level shallower:

The key is always present once the client asked for the relationship, so an absent key means only that the relationship was not requested. Both ways of writing an empty relationship produce the same output:

Requesting a relationship with no matching include<Name>() method throws, so a misspelled include stays loud rather than silently resolving to an empty value.

Include paths compose as a set, not an ordered list of instructions. A parent and a path nested under it may both be requested, in either order, and both are honoured; a repeated path is harmless; and the rendered tree is the union of every path requested. That makes the usual controller pattern safe:

A client sending ?include=criteria yields ['criteria', 'criteria.courseComponent', 'criteria'], and the nested courseComponent still renders. The order in which keys appear inside the relationships object is not part of the contract, so compare payloads by structure rather than byte-for-byte across differently-ordered include lists.

Strict validation rule

The strict rule asserts the native PHP type of a value rather than accepting anything that could be coerced into that type. The service provider registers it while register.validation_rules is true (the default) in config/lodash.php; setting the flag to false leaves Laravel's stock validator (or your own resolver) in place and the rule unregistered.

Accepted type arguments are int, integer, float, double, bool and boolean, plus any name gettype() returns, such as string or array. Omitting the argument throws an InvalidArgumentException when the rule runs; like any non-implicit rule, strict is skipped for absent, null, and empty-string values.

The package ships no message line for the rule, so a failing strict renders the raw key validation.strict until you define one. Add a line to your application's lang/en/validation.php; the :type placeholder is replaced with the declared type argument:

Because the check is on the native type, the rule is stricter than Laravel's own: strict:integer rejects the string '5' that integer accepts. Keep in mind that query-string and form-encoded values always arrive as strings, so strict:integer fits JSON payloads, or data already cast before validation.

On an attribute whose strict type is numeric (int, integer, float, double), the size rules min, max, size, between, gt, gte, lt and lte compare the value as a number, and failure messages use the numeric wording. Laravel's own integer or numeric rule is not needed alongside. Other strict types keep the framework's default sizing: ['strict:string', 'max:5'] still rejects '999999999' for being nine characters long.

Artisan Commands

The service provider is auto-discovered and register.commands defaults to true, so these commands are available out of the box. Set it to false in config/lodash.php to leave them unregistered.

Command Description
php artisan clear-all Clear entire cache and all cached routes, views, etc.
php artisan db:clear Drop all tables from database. Options:
--database= : The database connection to use.
--force : Force the operation to run when in production.
--pretend : Dump the SQL queries that would be run.
php artisan db:dump Dump database to sql file using mysqldump CLI utility. Options:
--database= : The database connection to use.
--path= : Folder path for store database dump files.
php artisan db:restore {file} Restore database from sql file using mysqldump CLI utility. Options:
--database= : The database connection to use.
--force : Force the operation to run when in production
php artisan log:clear Clear log files from storage/logs recursively. Options:
--force : Force the operation to run when in production.
php artisan user:add {email} {password?} Create a new user. Options:
--guard= : The guard to use.
php artisan user:password {email} {password?} Update/reset user password. Options:
--guard= : The guard to use.

Middleware List

XssSecurity

Sets XSS Security headers. Can be configured excluded URI-s, etc in the config/lodash.php .

SimpleBasicAuth

Add simple basic auth to a route.

In the config/auth.php you have to add:

Misc

SelfDiagnosis Checks

For using this checks, you have to install the package: laravel-self-diagnosis

Available Disk Space Check

Filesystem Disks Are Available

Elasticsearch Health Check

Php Ini Options Check

Php Ini Options Check

Servers Are Pingable Check

Horizon is running

Testing Helpers

The Longman\LaravelLodash\Testing\Response class extends Laravel's TestResponse with assertions for JSON envelopes of the shape {status, message, data, meta}. Wire it into your base test case by overriding createTestResponse():

Register your application's envelope shapes once (for example in the base test case's setUp()):

Structure assertions validate data as a single item or as a collection. Collection assertions validate every row and fail with readable messages when data is missing, empty, or not a list. With exact: true any missing or unexpected extra key inside data (and inside meta.pagination when pager or cursor meta is included) fails the test, while envelope keys outside those subtrees stay loosely checked:

Reusable structures live in a DataStructuresProvider subclass, one static property per structure:

Relation includes accept dots for linear chains and nested arrays for branching. Each segment is name or name[] (collection), optionally followed by :StructureName when the structure name differs from the relation key. Overlapping declarations merge, regardless of order:

The legacy '[roles]' wrapper syntax is not supported; declarations like it throw an InvalidArgumentException with a migration hint (write 'roles[]' instead).

A single relation that may render as null is declared with a ? suffix. One structure then covers both the populated and the empty case, under exact and non-exact matching, while a missing relationship key still fails with a message naming the relation:

The marker cannot be combined with the collection marker ('roles[]?' and 'roles?[]' both throw), because a relationship collection never renders as null. Structures containing a ? marker must be asserted through Testing\Response, which resolves the marker against the actual payload; passing one to Laravel's raw assertJsonStructure() would assert against a key that does not exist in the response. Under a collection relation the rows must agree: the marker resolves to the empty form only when every observed row has that relationship null.

The combined resource assertions tie a response to the exact records it should contain. Register the provider once, then a single call checks the structure (exact by default), the wire type (defaults to the structure name, override with type:), and the record identity. Expected ids derive from (string) $model->getKey(), or getUidString() for UUID-primary models:

On paginated endpoints the id comparison covers the current page. Resources with conditional fields can opt out of exactness with exact: false.

TODO

write more tests and add more features

Troubleshooting

If you like living on the edge, please report any bugs you find on the laravel-lodash issues page.

Contributing

Pull requests are welcome. See CONTRIBUTING.md for information.

License

Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.

Credits

Full credit list in Contributors


All versions of laravel-lodash with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
laravel/framework Version ^13.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 longman/laravel-lodash contains the following files

Loading the files please wait ...