Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Colada X Laravel Package

alexeyshockov/colada-x

colada-x is a tiny Laravel/PHP helper package by alexeyshockov. Lightweight and experimental, it offers small utilities you can drop into a project quickly. Best for tinkerers who don’t mind minimal docs, few stars, and a still-maturing API.

View on GitHub
Deep Wiki
Context7

\Colada\x()

Helper function for simplify callbacks.

Latest Stable Version Scrutinizer Code Quality Build Status

Installation

$ composer require alexeyshockov/colada-x

Usage

With ColadaX:

$activeUsers = array_filter($users, \Colada\x()->isActive());
$role = 'ADMIN';
$administrators = array_filter($users, \Colada\x()->hasRole($role));

Instead of pure PHP:

$activeUsers = array_filter($users, function ($user) {
    return $user->isActive();
});
$role = 'ADMIN';
$activeUsers = array_filter($users, function ($user) use ($role) {
    return $user->hasRole($role);
});

Useful together

Some code examples for your imagination.

Laravel 5 Collections

$activeUsers = $users->filter(\Colada\x()->isActive());

PHP Collection (schmittjoh/php-collection)

$activeUsers = $users->filter(\Colada\x()->isActive());

functional-php (lstrojny/functional-php)

The library already has partial_method function, but it's less powerful.

use Functional as F;

$activeUsers = F\select($users, \Colada\x()->isActive());

Less useful, but still

Doctrine 2 Collections (Symfony 2, Doctine 2 ORM, etc.)

// __asClosure() is needed because all Doctrine's methods accept only \Closure instances :(
$hasActiveUsers = $users->exists(\Colada\x()->isActive()->__asClosure());

Laravel 4 Collections

The same problem as described above with Doctrine.

Alernatives

If you need only the basic functionaly, take a look at invoke(), invoke_first(), invoke_if(), invoke_last(), invoker() from a great functional-php library.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor