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
Transforming Magento (NomadMage 2017)
Search
Christopher Pitt
April 19, 2017
Programming
2
88
Transforming Magento (NomadMage 2017)
Christopher Pitt
April 19, 2017
Tweet
Share
More Decks by Christopher Pitt
See All by Christopher Pitt
Making Robots (PHP Unicorn Conf)
chrispitt
1
160
Forget What You Know
chrispitt
1
130
Monads In PHP → php[tek]
chrispitt
3
480
Breaking The Enigma → php[tek]
chrispitt
0
170
Turn on the Generator!
chrispitt
0
150
Implementing Languages (FluentConf)
chrispitt
1
320
Async PHP (Sunshine)
chrispitt
0
430
Helpful Robot
chrispitt
0
100
Async PHP
chrispitt
14
7.3k
Other Decks in Programming
See All in Programming
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
2
400
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
170
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
250
Rubyで始める関数型ドメインモデリング
shogo_tksk
0
110
XStateを用いた堅牢なReact Components設計~複雑なClient Stateをシンプルに~ @React Tokyo ミートアップ #2
kfurusho
1
900
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
Formの複雑さに立ち向かう
bmthd
1
850
Spring gRPC について / About Spring gRPC
mackey0225
0
220
ファインディLT_ポケモン対戦の定量的分析
fufufukakaka
0
710
Amazon S3 TablesとAmazon S3 Metadataを触ってみた / 20250201-jawsug-tochigi-s3tables-s3metadata
kasacchiful
0
160
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
4
390
2024年のWebフロントエンドのふりかえりと2025年
sakito
2
250
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6.2k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
BBQ
matthewcrist
87
9.5k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
4
330
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Thoughts on Productivity
jonyablonski
69
4.5k
Raft: Consensus for Rubyists
vanstee
137
6.8k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
How GitHub (no longer) Works
holman
314
140k
Being A Developer After 40
akosma
89
590k
Optimizing for Happiness
mojombo
376
70k
Transcript
TRANSFORMING MAGENTO
HI
THANKS: NOMADMAGE AND NOMADPHP
DISCLAIMER: I'M REALLY NEW
DISCLAIMER: HERE BE DRAGONS
! composer require tinify/magento2
LOOK AT THESE GETTERS AND SETTERS
EVER MISS FEATURES FROM ANOTHER LANGUAGE?
TECHNICALLY: MAGIC METHODS
IMAGINE WE COULD USE THIS SYNTAX...
ALAS, THE TESTS FAIL
! composer require pre/class-accessors
WHAT'S THIS, THE TESTS PASS
WHAT HAPPENED?
WHAT IF WE WANT OUR OWN MAGIC METHODS?
YOU HEAR ABOUT THE TRAILING COMMAS PROPOSAL?
wiki.php.net/rfc/list-syntax-trailing-commas
SIDETRACK: STRANGE INCONSISTENCIES...
LET'S TRY
! composer require pre/trailing-commas
SOMETHING SERIOUSER
HANDS UP IF YOU'VE EVER USED DEPENDENCY INJECTION
LOOK AT THAT XML!
! composer require pre/parameter-loaders
! composer require pre/property-loaders
CODE YOUR MUM WOULD APPROVE OF
SOMETHING SIMPLER
EVER OPEN A FILE HANDLE ...OR CREATE A MUTEX LOCK?
CAN'T RETURN IMMEDIATELY BECAUSE OF STUPID FILES
! composer require pre/deferred
WITH 50% MORE BLOCKS
$handle = fopen("path/to/file); defer { fclose($handle); unlink("path/to/file"); } return fgets($handle);
HOW DOES THIS WORK?
SPOILERS: JUNE 22ND, NOMADPHP
PAUL'S [FOURTH] STANDARDS RECOMMENDATION
COMPILES: File.pre ! File.php
github.com/marcioAlmada/yay
WHAT DOES THIS CODE LOOK LIKE?
class Sprocket { public $name = new Translatable(static::class); public function
turn($spanner = factory("spanner")) { return $spanner->use($this); } }
class Sprocket { use \Pre\PropertyLoaders\PropertyLoadersTrait; private $name; private function loadNameProperty()
{ $this->name = new Translatable(static::class); } public function turn($spanner = null) { if (is_null($spanner)) { $spanner = factory("spanner"); } return $spanner->use($this); } }
! composer require friendsofphp/php-cs-fixer
IS IT SLOW?
! composer du -o
! composer dump-autoload --optimize
MAKES A LOCK FILE
GREAT FOR DEV GREAT FOR PROD
CAN I USE THIS TO MAKE MY OWN SYNTAX?
OTHER THINGS: ▸ immutable classes ▸ short arrow functions
WHY WOULD I USE THIS?
REASONS TO USE: ▸ You like the syntax I've shown
▸ You repeat code ▸ You repeat code
REASONS TO USE: ▸ New syntax could be clearer and
more concise ▸ You want features from other languages ▸ You want to support old PHP
process .."/helpers.pre";
process __DIR__ . "/helpers.pre";
\Pre\processAndRequire(__DIR__ . "/helpers.pre");
process __DIR__ . "/helpers.pre";
process .."/helpers.pre";
REASONS NOT TO USE: ▸ No IDE support ▸ You
have to teach developers new syntax ▸ You have to learn how .gitignore files work
HOW TO GET THOSE REASONS OFF THE PLANE: [HUMANELY] ▸
Pay someone to develop IDE support (or do it yourself) ▸ Help me make the docs better ▸ Learn how .gitignore files work
twitter.com/assertchris preprocess.io