Download the PHP package code-distortion/laravel-collection-macros without Composer

On this page you can find all versions of the php package code-distortion/laravel-collection-macros. 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-collection-macros

A set of useful Laravel collection macros

Latest Version on Packagist PHP from Packagist Laravel GitHub Workflow Status

This package is a fork of spatie/laravel-collection-macros. It contains a subset of the original macros as well as a few extra ones.

This package is intended for PERSONAL USE. Please see the original Spatie package if you would like to submit a PR or request a feature.

Installation

Install the package via composer:

The package will automatically register itself.

Macros

Macros kept from the original spatie package:

New macros added:

catch

See Try

extract

Extract keys from a collection. This is very similar to only, with two key differences:

extract is useful when using PHP 7.1 short list() syntax.

glob

Returns a collection of a glob() result.

ifAny

Executes the passed callable if the collection isn't empty. The entire collection will be returned.

ifEmpty

Executes the passed callable if the collection is empty. The entire collection will be returned.

keepValues

Returns a collection containing only values that were in the given list.

keepValues accepts a second parameter to turn strict-comparisons on (default false).

keyedKeys

Returns a collection where the values are the same as the keys.

none

Checks whether a collection doesn't contain any occurrences of a given item, key-value pair, or passing truth test. The function accepts the same parameters as the contains collection method.

paginate

Create a LengthAwarePaginator instance for the items in the collection.

This paginates the contents of $posts with 5 items per page. paginate accepts quite some options, head over to the Laravel docs for an in-depth guide.

prioritize

Move elements to the start of the collection.

rejectValues

Removes the given values from the collection.

rejectValues accepts a second parameter to turn strict-comparisons on (default false).

simplePaginate

Create a Paginator instance for the items in the collection.

This paginates the contents of $posts with 5 items per page. simplePaginate accepts quite some options, head over to the Laravel docs for an in-depth guide.

For a in-depth guide on pagination, check out the Laravel docs.

try

If any of the methods between try and catch throw an exception, then the exception can be handled in catch.

While the methods are named try/catch for familiarity with PHP, the collection itself behaves more like a database transaction. So when an exception is thrown, the original collection (before the try) is returned.

You may gain access to the collection within catch by adding a second parameter to your handler. You may also manipulate the collection within catch by returning a value.

transpose

The goal of transpose is to rotate a multidimensional array, turning the rows into columns and the columns into rows.

validate

Returns true if the given $callback returns true for every item. If $callback is a string or an array, regard it as a validation rule.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Contributions are not being sought for this package. Please see the original spatie/laravel-collection-macros package if you would like to contribute.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-collection-macros with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
illuminate/support Version ^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 code-distortion/laravel-collection-macros contains the following files

Loading the files please wait ....