Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
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
620
Communities and contribution
opdavies
0
340
Working without Workspace
opdavies
0
370
Things you should know about PHP
opdavies
1
920
An Introduction to Mob Programming
opdavies
0
450
Deploying PHP applications with Ansible, Ansible Vault and Ansistrano
opdavies
0
6.6k
Other Decks in Technology
See All in Technology
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3.2k
【GCC2026】鉄拳8でのVFX開発事例
bandainamcostudios
PRO
0
300
2026-08-15 JAWS-UG 茨城 #16 Secrets ManagerにおけるSecret値の管理(Terraformの場合) / Secrets Manager Secrets
masasuzu
0
590
Android skills に学ぶ
kokiko
0
170
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.3k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.5k
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
長期運営で肥大化したExcelマスターデータの解消に向けた移行事例
gree_tech
PRO
0
440
RapidCopy2 Matrix I/Oエンジンによるファイルコピーソフトウェアの設計と実装
kengosawa2
1
380
AI駆動開発はどこまで来たのか? ファインディの最新実態調査で読み解く現在地 Devin Con Tokyo
akiratom
1
450
型落ちシンクライアント端末のPoEモジュールを自作したかった話
logica0419
0
410
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
5k
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
500
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
640
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
500
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
280
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
420
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
490
How GitHub (no longer) Works
holman
316
150k
Google's AI Overviews - The New Search
badams
0
1.1k
KATA
mclloyd
PRO
35
15k
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