How I Learned to Stop Worrying and Love Composer - php[world] 2015
-
Upload
joshua-warren -
Category
Software
-
view
419 -
download
0
Transcript of How I Learned to Stop Worrying and Love Composer - php[world] 2015
PRESENTED BY
JOSHUA WARREN
PRESENTED AT
PHPWORLD 2015
HOW I LEARNED TO STOP
WORRYING AND LOVE COMPOSER
JoshuaWarren.com
Slides will be available at joind.in/14788
#phpworld
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
JoshuaWarren.com
This concept was inspired by all of you at php[world] 2014
#phpworld
JoshuaWarren.com
“Bringing the entire world of PHP one step closer together”
#phpworld
JoshuaWarren.com
Cross-pollinating ideas between PHP frameworks and applications
#phpworld
JoshuaWarren.com
One common idea I heard repeatedly at php[world] 2014
#phpworld
JoshuaWarren.com
Open source allows us to pool our efforts
#phpworld
JoshuaWarren.com
We accomplish so much more together than we could on
our own
#phpworld
JoshuaWarren.com
Composer is an amazing tool that breaks down barriers to
re-using open source libraries
#phpworld
JoshuaWarren.com
Every framework represented at php[world] can be used with
composer
#phpworld
JoshuaWarren.com
Many of the frameworks here can be installed with Composer,
including Magento 2
#phpworld
JoshuaWarren.com
Many of the frameworks, though - especially those closest to
end-users - use their own module formats
#phpworld
JoshuaWarren.com
That’s a problem
#phpworld
JoshuaWarren.com
The community around each framework is developing in their
own silo
#phpworld
JoshuaWarren.com
We’re duplicating (wasting!) massive amounts of effort
#phpworld
JoshuaWarren.com
We all hate spam, right?
#phpworld
JoshuaWarren.com
if Akismet makes a breaking change, that’s 8 developers that need to make the same updates
#phpworld
JoshuaWarren.com
Repeat this exercise on packagist for any popular technology
#phpworld
JoshuaWarren.com
We’re wasting so much of our effort on duplicating each
other’s work needlessly
#phpworld
JoshuaWarren.com
Thousands of developer-hours a year are wasted just building framework-specific solutions
#phpworld
JoshuaWarren.com
In the words of Bob Newhart on Mad TV…
#phpworld
JoshuaWarren.com
STOP IT!
#phpworld
JoshuaWarren.com
No excuses, just stop it.
#phpworld
JoshuaWarren.com
Let’s write composer packages that can work on all
frameworks
#phpworld
JoshuaWarren.com
contribute to existing PHP packages instead of creating framework-specific packages
#phpworld
JoshuaWarren.com
We’re smart people. We’re developers. You could even say…
#phpworld
JoshuaWarren.com
We can revolutionize the web if we focus our efforts on
solving new problems
#phpworld
JoshuaWarren.com
There’s three steps to making this change
#phpworld
JoshuaWarren.com
Step 1: change your way of thinking
#phpworld
JoshuaWarren.com
Stop looking for framework-specific extensions
#phpworld
JoshuaWarren.com
Start your search on Packagist
#phpworld
JoshuaWarren.com
If you find a library that doesn’t do quite what you need, improve
it
#phpworld
JoshuaWarren.com
Adapt those existing libraries to your framework
#phpworld
JoshuaWarren.com
You benefit - you don’t have to re-write functionality someone
else has already written
#phpworld
JoshuaWarren.com
The package author benefits from your feedback and
contributions
#phpworld
JoshuaWarren.com
The entire community benefits from having a focused group of
high-quality packages
#phpworld
JoshuaWarren.com
Adapting these libraries to your framework gets time consuming
#phpworld
JoshuaWarren.com
If only we had access to some sort of tool that could easily automate repetitive actions…
#phpworld
JoshuaWarren.com
Step 2: Develop a community standard
for universal PHP libraries
#phpworld
JoshuaWarren.com
There are two ways to approach universal PHP packages
#phpworld
JoshuaWarren.com
First - packages that have multi-framework support built in
#phpworld
JoshuaWarren.com
Each package contains everything needed for that package to run on all PHP
frameworks
#phpworld
JoshuaWarren.com
This puts more work on the package author, but less work
on the frameworks and the package users
#phpworld
JoshuaWarren.com
The second approach is to build a standard, universal package
format
#phpworld
JoshuaWarren.com
Each framework would then need an adapter or bridge to understand these packages
#phpworld
JoshuaWarren.com
Simplifies things for package authors
#phpworld
JoshuaWarren.com
Early package users have more work to do - each framework
will need an adapter
#phpworld
JoshuaWarren.com
Once an adapter for each framework is written, this
approach is easier for everyone
#phpworld
JoshuaWarren.com
A Symfony developer has found the solution for this approach…
#phpworld
JoshuaWarren.com
Puli: no longer just a unique looking dog breed
#phpworld
JoshuaWarren.com
“Puli aims to replace specialized packages of different
frameworks with one generic, framework independent
solution.”
#phpworld
JoshuaWarren.com
Puli, like Composer, has both a command-line tool and a JSON-
based config file
#phpworld
JoshuaWarren.com
Puli adds a layer on top of Composer, but doesn’t replace it
#phpworld
JoshuaWarren.com
Puli packages are also Composer packages
#phpworld
JoshuaWarren.com
Puli provides a naming convention to access non-PHP
files from a Puli package
#phpworld
JoshuaWarren.com
CSS, images, etc., are stored within the Puli package and mapped to their framework-
specific locations
#phpworld
JoshuaWarren.com
Puli packages can be both consumers and providers of resources and PHP classes
#phpworld
JoshuaWarren.com
Learn more about Puli at puli.io or on Speakerdeck.
#phpworld
JoshuaWarren.com
Puli has a Symfony bundle/bridge, allowing Puli packages
to work out of the box with Symfony
#phpworld
JoshuaWarren.com
Similar bridges are needed for other frameworks
#phpworld
JoshuaWarren.com
Puli is the most developed attempt at solving the universal
package problem in PHP
#phpworld
JoshuaWarren.com
Puli isn’t perfect
#phpworld
JoshuaWarren.com
Doesn’t handle frameworks that manipulate non-PHP config
files directly on disk (I’m looking at you, Magento)
#phpworld
JoshuaWarren.com
Hoping to spark a discussion and debate around universal
packages for PHP
#phpworld
JoshuaWarren.com
If Puli is the best approach, let’s get it integrated with our
frameworks
#phpworld
JoshuaWarren.com
Which takes us to…
#phpworld
JoshuaWarren.com
Step 3:
#phpworld
JoshuaWarren.com
Change the community’s way of thinking
#phpworld
JoshuaWarren.com
Start conversations at your local PHP user group about how
much effort we currently duplicate
#phpworld
JoshuaWarren.com
Start discussing the two different approaches to solving
the problem
#phpworld
JoshuaWarren.com
Introduce people to Puli & provide feedback on Github to
the Puli project
#phpworld
JoshuaWarren.com
Implement a Puli integration for your favorite framework
#phpworld
JoshuaWarren.com
When you see someone duplicating effort by writing a framework-specific extension,
tell them…
#phpworld
JoshuaWarren.com
STOP IT!
#phpworld
JoshuaWarren.com
Show them how to re-use an existing PHP package via
Composer
#phpworld
JoshuaWarren.com
Start your new projects as Composer packages, not
application-specific extensions
#phpworld
JoshuaWarren.com
Frameworks like Laravel have revolutionized the web by
reducing the amount of time we waste writing boilerplate
#phpworld
JoshuaWarren.com
Think about what we can do as a community if we stop duplicating
each other’s work
#phpworld
JoshuaWarren.com
Let’s start working together to solve new problems
#phpworld
JoshuaWarren.com
We can change the web - and the world
#phpworld
Keep in Touch!
@JoshuaSWarren
JoshuaWarren.com
Mage2DevBook.com
joind.in/14788
JoshuaWarren.com #phpworld