32
DEPLOYING PHP APPLICATIONS By Niklas Modess

Deploying php applications

Embed Size (px)

DESCRIPTION

The world of PHP is very interesting right now and it has been catching up on best coding practices. It's time we bring our deploy processes up to par with this and start using best practices for it as well. So what are the goals for it and which steps can be taken to reach them? How can we make the process fit better into the more and more Agile world we live in?

Citation preview

Page 1: Deploying php applications

DEPLOYING PHPAPPLICATIONS

By Niklas Modess

Page 2: Deploying php applications

WHO AM I?@niklasmodess

codingswag.com

Freelance / consultant web architect

Developed and deployed PHP applications for 10+ years

Currently developing mostly in Laravel

Co-organizer of the meetup group Laravel Stockholm

Page 3: Deploying php applications

THE BOOK

https://leanpub.com/deploying-php-

applications/c/SYMFONYCAMP

$9.99 with this link ($5 discount)

Page 4: Deploying php applications

WHY AM I HERE?To sell my book ;)

To spread deployment process awareness

Discuss goals and steps for deployment

Page 5: Deploying php applications

WHAT I'M NOT HERE FORTalk about deployment tools

Talk about server provisioning tools

Show you commands

Show you code

Discuss system specific things

Page 6: Deploying php applications

WHY SHOULD WE TALK ABOUT THIS?It's about time we do it

Helps our entire development process

Gain confidence as a developer

Page 7: Deploying php applications

THE PHP WORLD

Page 8: Deploying php applications

PHP: a fractal of bad design

FUCK THE HATERS

Page 9: Deploying php applications

EXCITING TIMES!Best practices

Testing

Continous integration

.. and even OOP

Page 10: Deploying php applications

BUT...What happened to deployment in all this?

Page 11: Deploying php applications

THE AGILE WORLDAgile: "Characterized by quickness, lightness,

and ease of movement."

Page 12: Deploying php applications

Staying agile with deployment is about

RESPONDING QUICKLYTO FEEDBACK

Page 13: Deploying php applications

Work in

SPRINTSbut plan for the

MARATHON

Page 14: Deploying php applications

RELEASE CYCLESThe new version is done, ship it.

I'm done, ship it.

X amount of time has passed, ship it.

I pushed it, ship it.

Page 15: Deploying php applications

ENVIRONMENTS

Page 16: Deploying php applications

THE USUAL ONESLocal

Development

Staging

Production

(Testing)

Page 17: Deploying php applications

QUESTIONSDo we have separate environments?

Are they repeatable/provisioned?

Do we have a branching strategy for our version control?

Staging as close to production as possible?

Page 18: Deploying php applications

PITFALL #1This:

{ id: 1}

Can turn into this:

{ id: "1"}

Page 19: Deploying php applications

PITFALL #2PascalCasedClass.php

class PascalCasedClass {}

index.php

require_once('Pascalcasedclass.php');

Will only work in enviroment that handles its file system case

insensitive.

Page 20: Deploying php applications

I LIKE DIVERSITYAs long as it stays out of my software environments

Page 21: Deploying php applications

THE STORY ABOUT AN APPLICATION.. come up with an idea

.. do some wireframes

.. code, code, code

.. celebrate finishing code

.. shit, we have to deploy it

.. well, do it quickly then

Page 22: Deploying php applications

The deployment process is almost always

AD HOCA reaction to your applications state

"Duct tape deployment""

Page 23: Deploying php applications

AUTOMATEEVERYTHING!

Page 24: Deploying php applications

MANUL STEPSAre the root of all evil

Page 25: Deploying php applications

AN EXAMPLE OF A MANUAL STEPclass Assets { const REVISION = 14;}

<link rel="stylesheet" href="style.css?v=<?=Assets::REVISION?>" type="text/css">

Page 26: Deploying php applications

THE GOALSIn a nice and ordered list

Page 27: Deploying php applications

WE WANT IT TO BEAutomated

Responsive

Atomic

Reversible

Simple

Fast

Agnostic

Page 28: Deploying php applications

ROLLBACKSAre just as important, and should comply with the goals

Page 29: Deploying php applications

MATURITYA quite natural process (hopefully)

Page 30: Deploying php applications

THE STEPSDocumentation

Automation

Verification

Notification

Tests

Tools

Monitoring

Page 31: Deploying php applications

WHAT COULD IT TAKE CARE OF?Running tests

Database migrations

Cache bust & warm up

Dependencies

Static assets/contents

Generate documentation

Restart services

Restart queues / workers

Symlink folders

... any tool with a cli or api

Page 32: Deploying php applications

THANK YOU!

QUESTIONS?