PRESENTED BY
JOSHUA
WARREN
PRESENTED AT
PHPWORLD
2015
HOW I LEARNED
TO STOP
WORRYING AND
LOVE COMPOSER
Slide 2
Slide 2 text
No content
Slide 3
Slide 3 text
JoshuaWarren.com
Slides will be available at
joind.in/14788
#phpworld
Slide 4
Slide 4 text
JoshuaWarren.com
My Experience
PHP Developer Since 1999
Founded Creatuity in 2008
Focused on the Magento platform
Previous experience w/WordPress, Joomla, Drupal, Yii
#phpworld
Slide 5
Slide 5 text
JoshuaWarren.com
This concept was inspired by
all of you at php[world] 2014
#phpworld
Slide 6
Slide 6 text
JoshuaWarren.com
“Bringing the entire world of
PHP one step closer together”
#phpworld
Slide 7
Slide 7 text
JoshuaWarren.com
Cross-pollinating ideas between
PHP frameworks and applications
#phpworld
Slide 8
Slide 8 text
JoshuaWarren.com
One common idea I heard
repeatedly at php[world] 2014
#phpworld
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
JoshuaWarren.com
Open source allows us to pool
our efforts
#phpworld
Slide 11
Slide 11 text
JoshuaWarren.com
We accomplish so much more
together than we could on
our own
#phpworld
Slide 12
Slide 12 text
JoshuaWarren.com
Composer is an amazing tool
that breaks down barriers to
re-using open source libraries
#phpworld
Slide 13
Slide 13 text
JoshuaWarren.com
Every framework represented
at php[world] can be used with
composer
#phpworld
Slide 14
Slide 14 text
JoshuaWarren.com
Many of the frameworks here
can be installed with Composer,
including Magento 2
#phpworld
Slide 15
Slide 15 text
JoshuaWarren.com
Many of the frameworks, though
- especially those closest to
end-users - use their own
module formats
#phpworld
Slide 16
Slide 16 text
JoshuaWarren.com
That’s a problem
#phpworld
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
No content
Slide 19
Slide 19 text
JoshuaWarren.com
The community around each
framework is developing in their
own silo
#phpworld
Slide 20
Slide 20 text
JoshuaWarren.com
We’re duplicating (wasting!)
massive amounts of effort
#phpworld
Slide 21
Slide 21 text
JoshuaWarren.com
We all hate spam, right?
#phpworld
Slide 22
Slide 22 text
No content
Slide 23
Slide 23 text
No content
Slide 24
Slide 24 text
No content
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
No content
Slide 27
Slide 27 text
No content
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
JoshuaWarren.com
if Akismet makes a breaking
change, that’s 8 developers that
need to make the same updates
#phpworld
Slide 31
Slide 31 text
JoshuaWarren.com
Repeat this exercise on packagist
for any popular technology
#phpworld
Slide 32
Slide 32 text
JoshuaWarren.com
We’re wasting so much of our
effort on duplicating each
other’s work needlessly
#phpworld
Slide 33
Slide 33 text
JoshuaWarren.com
Thousands of developer-hours
a year are wasted just building
framework-specific solutions
#phpworld
Slide 34
Slide 34 text
JoshuaWarren.com
In the words of Bob Newhart on
Mad TV…
#phpworld
Slide 35
Slide 35 text
JoshuaWarren.com
STOP IT!
#phpworld
Slide 36
Slide 36 text
JoshuaWarren.com
No excuses, just stop it.
#phpworld
Slide 37
Slide 37 text
JoshuaWarren.com
Let’s write composer packages
that can work on all
frameworks
#phpworld
Slide 38
Slide 38 text
JoshuaWarren.com
contribute to existing PHP
packages instead of creating
framework-specific packages
#phpworld
Slide 39
Slide 39 text
JoshuaWarren.com
We’re smart people. We’re
developers. You could even say…
#phpworld
Slide 40
Slide 40 text
No content
Slide 41
Slide 41 text
JoshuaWarren.com
We can revolutionize the web
if we focus our efforts on
solving new problems
#phpworld
Slide 42
Slide 42 text
JoshuaWarren.com
There’s three steps to making
this change
#phpworld
Slide 43
Slide 43 text
JoshuaWarren.com
Step 1:
change your way of thinking
#phpworld
Slide 44
Slide 44 text
JoshuaWarren.com
Stop looking for framework-
specific extensions
#phpworld
Slide 45
Slide 45 text
JoshuaWarren.com
Start your search on Packagist
#phpworld
Slide 46
Slide 46 text
JoshuaWarren.com
If you find a library that doesn’t
do quite what you need, improve
it
#phpworld
Slide 47
Slide 47 text
JoshuaWarren.com
Adapt those existing libraries to
your framework
#phpworld
Slide 48
Slide 48 text
JoshuaWarren.com
You benefit - you don’t have to
re-write functionality someone
else has already written
#phpworld
Slide 49
Slide 49 text
JoshuaWarren.com
The package author benefits
from your feedback and
contributions
#phpworld
Slide 50
Slide 50 text
JoshuaWarren.com
The entire community benefits
from having a focused group of
high-quality packages
#phpworld
Slide 51
Slide 51 text
JoshuaWarren.com
Adapting these libraries to your
framework gets time consuming
#phpworld
Slide 52
Slide 52 text
JoshuaWarren.com
If only we had access to some
sort of tool that could easily
automate repetitive actions…
#phpworld
Slide 53
Slide 53 text
No content
Slide 54
Slide 54 text
JoshuaWarren.com
Step 2:
Develop a community standard
for universal PHP libraries
#phpworld
Slide 55
Slide 55 text
JoshuaWarren.com
There are two ways to approach
universal PHP packages
#phpworld
Slide 56
Slide 56 text
JoshuaWarren.com
First - packages that have multi-
framework support built in
#phpworld
Slide 57
Slide 57 text
JoshuaWarren.com
Each package contains
everything needed for that
package to run on all PHP
frameworks
#phpworld
Slide 58
Slide 58 text
JoshuaWarren.com
This puts more work on the
package author, but less work
on the frameworks and the
package users
#phpworld
Slide 59
Slide 59 text
JoshuaWarren.com
The second approach is to build
a standard, universal package
format
#phpworld
Slide 60
Slide 60 text
JoshuaWarren.com
Each framework would then
need an adapter or bridge to
understand these packages
#phpworld
Slide 61
Slide 61 text
JoshuaWarren.com
Simplifies things for package
authors
#phpworld
Slide 62
Slide 62 text
JoshuaWarren.com
Early package users have more
work to do - each framework
will need an adapter
#phpworld
Slide 63
Slide 63 text
JoshuaWarren.com
Once an adapter for each
framework is written, this
approach is easier for everyone
#phpworld
Slide 64
Slide 64 text
JoshuaWarren.com
A Symfony developer has found
the solution for this approach…
#phpworld
Slide 65
Slide 65 text
No content
Slide 66
Slide 66 text
JoshuaWarren.com
Puli: no longer just a unique
looking dog breed
#phpworld
Slide 67
Slide 67 text
No content
Slide 68
Slide 68 text
JoshuaWarren.com
puli.io - Universal Packages for
PHP
#phpworld
Slide 69
Slide 69 text
JoshuaWarren.com
“Puli aims to replace specialized
packages of different
frameworks with one generic,
framework independent
solution.”
#phpworld
Slide 70
Slide 70 text
JoshuaWarren.com
Puli, like Composer, has both a
command-line tool and a JSON-
based config file
#phpworld
Slide 71
Slide 71 text
JoshuaWarren.com
Puli adds a layer on top of
Composer, but doesn’t replace it
#phpworld
Slide 72
Slide 72 text
JoshuaWarren.com
Puli packages are also
Composer packages
#phpworld
Slide 73
Slide 73 text
JoshuaWarren.com
Puli provides a naming
convention to access non-PHP
files from a Puli package
#phpworld
Slide 74
Slide 74 text
JoshuaWarren.com
CSS, images, etc., are stored
within the Puli package and
mapped to their framework-
specific locations
#phpworld
Slide 75
Slide 75 text
JoshuaWarren.com
Puli packages can be both
consumers and providers of
resources and PHP classes
#phpworld
Slide 76
Slide 76 text
JoshuaWarren.com
Learn more about Puli at puli.io
or on Speakerdeck.
#phpworld
Slide 77
Slide 77 text
JoshuaWarren.com
Puli has a Symfony bundle/
bridge, allowing Puli packages
to work out of the box with
Symfony
#phpworld
Slide 78
Slide 78 text
JoshuaWarren.com
Similar bridges are needed for
other frameworks
#phpworld
Slide 79
Slide 79 text
JoshuaWarren.com
Puli is the most developed
attempt at solving the universal
package problem in PHP
#phpworld
Slide 80
Slide 80 text
JoshuaWarren.com
Puli isn’t perfect
#phpworld
Slide 81
Slide 81 text
JoshuaWarren.com
Doesn’t handle frameworks
that manipulate non-PHP config
files directly on disk
(I’m looking at you, Magento)
#phpworld
Slide 82
Slide 82 text
JoshuaWarren.com
Hoping to spark a discussion and
debate around universal
packages for PHP
#phpworld
Slide 83
Slide 83 text
JoshuaWarren.com
If Puli is the best approach, let’s
get it integrated with our
frameworks
#phpworld
Slide 84
Slide 84 text
JoshuaWarren.com
Which takes us to…
#phpworld
Slide 85
Slide 85 text
JoshuaWarren.com
Step 3:
#phpworld
Slide 86
Slide 86 text
No content
Slide 87
Slide 87 text
JoshuaWarren.com
Change the community’s way of
thinking
#phpworld
Slide 88
Slide 88 text
JoshuaWarren.com
Start conversations at your
local PHP user group about how
much effort we currently
duplicate
#phpworld
Slide 89
Slide 89 text
JoshuaWarren.com
Start discussing the two
different approaches to solving
the problem
#phpworld
Slide 90
Slide 90 text
JoshuaWarren.com
Introduce people to Puli &
provide feedback on Github to
the Puli project
#phpworld
Slide 91
Slide 91 text
JoshuaWarren.com
Implement a Puli integration for
your favorite framework
#phpworld
Slide 92
Slide 92 text
JoshuaWarren.com
When you see someone
duplicating effort by writing a
framework-specific extension,
tell them…
#phpworld
Slide 93
Slide 93 text
JoshuaWarren.com
STOP IT!
#phpworld
Slide 94
Slide 94 text
JoshuaWarren.com
Show them how to re-use an
existing PHP package via
Composer
#phpworld
Slide 95
Slide 95 text
JoshuaWarren.com
Start your new projects as
Composer packages, not
application-specific extensions
#phpworld
Slide 96
Slide 96 text
JoshuaWarren.com
Frameworks like Laravel have
revolutionized the web by
reducing the amount of time we
waste writing boilerplate
#phpworld
Slide 97
Slide 97 text
JoshuaWarren.com
Think about what we can do as a
community if we stop duplicating
each other’s work
#phpworld
Slide 98
Slide 98 text
JoshuaWarren.com
Let’s start working together to
solve new problems
#phpworld
Slide 99
Slide 99 text
JoshuaWarren.com
We can change the web - and
the world
#phpworld
Slide 100
Slide 100 text
Keep in
Touch!
@JoshuaSWarren
JoshuaWarren.com
Mage2DevBook.com
joind.in/14788