How I Learned to Stop Worrying and Love Composer - php[world] 2015

101
PRESENTED BY JOSHUA WARREN PRESENTED AT PHPWORLD 2015 HOW I LEARNED TO STOP WORRYING AND LOVE COMPOSER

Transcript of How I Learned to Stop Worrying and Love Composer - php[world] 2015

Page 1: 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

Page 2: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 3: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Slides will be available at joind.in/14788

#phpworld

Page 4: How I Learned to Stop Worrying and Love Composer - php[world] 2015

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

Page 5: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

This concept was inspired by all of you at php[world] 2014

#phpworld

Page 6: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

“Bringing the entire world of PHP one step closer together”

#phpworld

Page 7: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Cross-pollinating ideas between PHP frameworks and applications

#phpworld

Page 8: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

One common idea I heard repeatedly at php[world] 2014

#phpworld

Page 9: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 10: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Open source allows us to pool our efforts

#phpworld

Page 11: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

We accomplish so much more together than we could on

our own

#phpworld

Page 12: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Composer is an amazing tool that breaks down barriers to

re-using open source libraries

#phpworld

Page 13: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Every framework represented at php[world] can be used with

composer

#phpworld

Page 14: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Many of the frameworks here can be installed with Composer,

including Magento 2

#phpworld

Page 15: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Many of the frameworks, though - especially those closest to

end-users - use their own module formats

#phpworld

Page 16: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

That’s a problem

#phpworld

Page 17: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 18: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 19: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

The community around each framework is developing in their

own silo

#phpworld

Page 20: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

We’re duplicating (wasting!) massive amounts of effort

#phpworld

Page 21: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

We all hate spam, right?

#phpworld

Page 22: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 23: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 24: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 25: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 26: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 27: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 28: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 29: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 30: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

if Akismet makes a breaking change, that’s 8 developers that need to make the same updates

#phpworld

Page 31: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Repeat this exercise on packagist for any popular technology

#phpworld

Page 32: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

We’re wasting so much of our effort on duplicating each

other’s work needlessly

#phpworld

Page 33: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Thousands of developer-hours a year are wasted just building framework-specific solutions

#phpworld

Page 34: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

In the words of Bob Newhart on Mad TV…

#phpworld

Page 35: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

STOP IT!

#phpworld

Page 36: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

No excuses, just stop it.

#phpworld

Page 37: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Let’s write composer packages that can work on all

frameworks

#phpworld

Page 38: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

contribute to existing PHP packages instead of creating framework-specific packages

#phpworld

Page 39: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

We’re smart people. We’re developers. You could even say…

#phpworld

Page 40: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 41: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

We can revolutionize the web if we focus our efforts on

solving new problems

#phpworld

Page 42: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

There’s three steps to making this change

#phpworld

Page 43: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Step 1: change your way of thinking

#phpworld

Page 44: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Stop looking for framework-specific extensions

#phpworld

Page 45: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Start your search on Packagist

#phpworld

Page 46: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

If you find a library that doesn’t do quite what you need, improve

it

#phpworld

Page 47: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Adapt those existing libraries to your framework

#phpworld

Page 48: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

You benefit - you don’t have to re-write functionality someone

else has already written

#phpworld

Page 49: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

The package author benefits from your feedback and

contributions

#phpworld

Page 50: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

The entire community benefits from having a focused group of

high-quality packages

#phpworld

Page 51: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Adapting these libraries to your framework gets time consuming

#phpworld

Page 52: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

If only we had access to some sort of tool that could easily automate repetitive actions…

#phpworld

Page 53: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 54: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Step 2: Develop a community standard

for universal PHP libraries

#phpworld

Page 55: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

There are two ways to approach universal PHP packages

#phpworld

Page 56: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

First - packages that have multi-framework support built in

#phpworld

Page 57: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Each package contains everything needed for that package to run on all PHP

frameworks

#phpworld

Page 58: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

This puts more work on the package author, but less work

on the frameworks and the package users

#phpworld

Page 59: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

The second approach is to build a standard, universal package

format

#phpworld

Page 60: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Each framework would then need an adapter or bridge to understand these packages

#phpworld

Page 61: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Simplifies things for package authors

#phpworld

Page 62: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Early package users have more work to do - each framework

will need an adapter

#phpworld

Page 63: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Once an adapter for each framework is written, this

approach is easier for everyone

#phpworld

Page 64: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

A Symfony developer has found the solution for this approach…

#phpworld

Page 65: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 66: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli: no longer just a unique looking dog breed

#phpworld

Page 67: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 68: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

puli.io - Universal Packages for PHP

#phpworld

Page 69: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

“Puli aims to replace specialized packages of different

frameworks with one generic, framework independent

solution.”

#phpworld

Page 70: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli, like Composer, has both a command-line tool and a JSON-

based config file

#phpworld

Page 71: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli adds a layer on top of Composer, but doesn’t replace it

#phpworld

Page 72: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli packages are also Composer packages

#phpworld

Page 73: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli provides a naming convention to access non-PHP

files from a Puli package

#phpworld

Page 74: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

CSS, images, etc., are stored within the Puli package and mapped to their framework-

specific locations

#phpworld

Page 75: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli packages can be both consumers and providers of resources and PHP classes

#phpworld

Page 76: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Learn more about Puli at puli.io or on Speakerdeck.

#phpworld

Page 77: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli has a Symfony bundle/bridge, allowing Puli packages

to work out of the box with Symfony

#phpworld

Page 78: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Similar bridges are needed for other frameworks

#phpworld

Page 79: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli is the most developed attempt at solving the universal

package problem in PHP

#phpworld

Page 80: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Puli isn’t perfect

#phpworld

Page 81: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Doesn’t handle frameworks that manipulate non-PHP config

files directly on disk (I’m looking at you, Magento)

#phpworld

Page 82: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Hoping to spark a discussion and debate around universal

packages for PHP

#phpworld

Page 83: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

If Puli is the best approach, let’s get it integrated with our

frameworks

#phpworld

Page 84: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Which takes us to…

#phpworld

Page 85: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Step 3:

#phpworld

Page 86: How I Learned to Stop Worrying and Love Composer - php[world] 2015
Page 87: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Change the community’s way of thinking

#phpworld

Page 88: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Start conversations at your local PHP user group about how

much effort we currently duplicate

#phpworld

Page 89: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Start discussing the two different approaches to solving

the problem

#phpworld

Page 90: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Introduce people to Puli & provide feedback on Github to

the Puli project

#phpworld

Page 91: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Implement a Puli integration for your favorite framework

#phpworld

Page 92: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

When you see someone duplicating effort by writing a framework-specific extension,

tell them…

#phpworld

Page 93: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

STOP IT!

#phpworld

Page 94: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Show them how to re-use an existing PHP package via

Composer

#phpworld

Page 95: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Start your new projects as Composer packages, not

application-specific extensions

#phpworld

Page 96: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Frameworks like Laravel have revolutionized the web by

reducing the amount of time we waste writing boilerplate

#phpworld

Page 97: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Think about what we can do as a community if we stop duplicating

each other’s work

#phpworld

Page 98: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

Let’s start working together to solve new problems

#phpworld

Page 99: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com

We can change the web - and the world

#phpworld

Page 100: How I Learned to Stop Worrying and Love Composer - php[world] 2015

Keep in Touch!

@JoshuaSWarren

JoshuaWarren.com

Mage2DevBook.com

joind.in/14788

Page 101: How I Learned to Stop Worrying and Love Composer - php[world] 2015

JoshuaWarren.com #phpworld