Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Using Laravel Collections... Outside Laravel
Search
Oliver Davies
August 28, 2018
Technology
2.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Using Laravel Collections... Outside Laravel
Oliver Davies
August 28, 2018
More Decks by Oliver Davies
See All by Oliver Davies
Building Static Websites with Sculpin
opdavies
0
1.7k
Taking Flight with Tailwind CSS
opdavies
0
5.6k
TDD - Test Driven Drupal
opdavies
0
4.4k
Building "Build Configs"
opdavies
0
650
Communities and contribution
opdavies
0
350
Working without Workspace
opdavies
0
410
Things you should know about PHP
opdavies
1
940
An Introduction to Mob Programming
opdavies
0
470
Deploying PHP applications with Ansible, Ansible Vault and Ansistrano
opdavies
0
6.6k
Other Decks in Technology
See All in Technology
事業成長とデータ活用を止めないためのマネジメントへ挑戦
hiracky16
0
410
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
0
190
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
900
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
3
1.1k
AI時代のPRレビューにどう向き合うか?
kairim0
1
250
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
690
会社説明資料
persolserverworks
0
9.8k
freeeにおけるSoftware Factory
freee
PRO
0
100
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
310
CTO Night|NotionのAIエージェントとFDE
kzkhykw1991
0
260
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
300
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
170
Featured
See All Featured
The browser strikes back
jonoalderson
0
1.8k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
450
Typedesign – Prime Four
hannesfritz
42
3.2k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
540
Scaling GitHub
holman
464
140k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Google's AI Overviews - The New Search
badams
0
1.6k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
It's Worth the Effort
3n
188
29k
Transcript
USING LARAVEL COLLECTIONS... OUTSIDE LARAVEL
COLLECTIONS
collect(['foo', 'bar']); // ['foo', 'bar'] collect('foobar'); // ['foobar'] $object =
new stdClass(); $object->foo = 'bar'; collect($object); // ['foo' => 'bar'] collect($object)->get('foo'); // bar
$collection = collect(['a', 'b', 1, 'c', 2, 'd', 'e', 3,
4]); $collection->count(); // 9 $collection->first(); // a $collection->first(function ($item) { return is_numeric($item); }); // 1 $collection->contains(2); // true $collection->contains([2, 10]); // false $collection->filter(function ($item) { return $item > 2; }); // [3, 4]
$collection = collect([ ['name' => 'John', 'email' => '
[email protected]
', 'age'
=> 31], ['name' => 'Jane', 'email' => '
[email protected]
', 'age' => 27], ]); $collection->pluck('name'); // ['John', 'Jane'] $collection->pluck('name')->sort(); // ['Jane', 'John'] $collection->filter(function ($person) { return $person['age'] >= 30; })->pluck('name'); // ['John']
None
THERE’S A MODULE FOR THAT! - DRUPALERS
THERE'S NOT A MODULE FOR THAT. - ME
None
VERSION 1.0 WRITE MY OWN COLLECTION CLASS
None
None
COLLECT - ILLUMINATE COLLECTIONS AS A SEPARATE PACKAGE. HTTPS://PACKAGIST.ORG/PACKAGES/TIGHTENCO/COLLECT
IMPORT LARAVEL'S COLLECTIONS INTO NON- LARAVEL PACKAGES EASILY, WITHOUT NEEDING
TO REQUIRE THE ENTIRE ILLUMINATE\SUPPORT PACKAGE. HTTPS://PACKAGIST.ORG/PACKAGES/TIGHTENCO/COLLECT
None
COMPOSER REQUIRE TIGHTENCO/COLLECT
None
None
VERSION 2.0 USE SOMEONE ELSE’S COLLECTION CLASS
None
▸ Install Composer ▸ Require tightenco/collect ▸ Include autoload.php ▸
collect() away!
▸ Install Composer ▸ Require tightenco/collect ▸ Include autoload.php ▸
collect() away!
// index.php require __DIR__ . '/vendor/autoload.php'; $collection = collect(['foo', 'bar']);
$collection->each(function ($item) { // Do something. });
None
None
None
THANKS! @OPDAVIES OLIVERDAVIES.UK