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
110
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
210
Forget What You Know
chrispitt
1
150
Monads In PHP → php[tek]
chrispitt
3
520
Breaking The Enigma → php[tek]
chrispitt
0
210
Turn on the Generator!
chrispitt
0
170
Implementing Languages (FluentConf)
chrispitt
1
350
Async PHP (Sunshine)
chrispitt
0
470
Helpful Robot
chrispitt
0
120
Async PHP
chrispitt
14
7.4k
Other Decks in Programming
See All in Programming
Software Architecture
hschwentner
6
2.3k
釣り地図SNSにおける有料機能の実装
nokonoko1203
0
200
Leading Effective Engineering Teams in the AI Era
addyosmani
7
610
登壇は dynamic! な営みである / speech is dynamic
da1chi
0
360
マンガアプリViewerの大画面対応を考える
kk__777
0
250
Claude Agent SDK を使ってみよう
hyshu
0
1.4k
Writing Better Go: Lessons from 10 Code Reviews
konradreiche
3
6.7k
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
12
7.1k
コード生成なしでモック処理を実現!ovechkin-dm/mockioで学ぶメタプログラミング
qualiarts
0
260
GC25 Recap: The Code You Reviewed is Not the Code You Built / #newt_gophercon_tour
mazrean
0
110
実践Claude Code:20の失敗から学ぶAIペアプログラミング
takedatakashi
18
8.5k
オンデバイスAIとXcode
ryodeveloper
0
130
Featured
See All Featured
Designing for Performance
lara
610
69k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
190
55k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
The Cult of Friendly URLs
andyhume
79
6.6k
Designing for humans not robots
tammielis
254
26k
The World Runs on Bad Software
bkeepers
PRO
72
11k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Docker and Python
trallard
46
3.6k
Building Adaptive Systems
keathley
44
2.8k
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