Static Site Generators, PHP and The Cuban Revolution

A presentation at PHPSW Lightning Talks in April 2018 in Bristol, UK by Drew McLellan

Slide 1

Slide 1

STATIC SITE GENERATORS, PHP & THE CUBAN REVOLUTION PHP SOUTHWEST

Slide 2

Slide 2

STATIC SITE GENERATORS, PHP & THE CUBAN REVOLUTION PHP SOUTHWEST

Slide 3

Slide 3

WHAT IS A STATIC SITE GENERATOR?

Slide 4

Slide 4

STATIC SITE GENERATORS AND PHP WHAT IS A STATIC SITE GENERATOR? ▸ A script or application that runs offline to combine content and templates into a set of finalised, static web pages. ▸ Content is commonly stored in Markdown files under source control. ▸ Often use an established templating library (Twig, Handlebars, Liquid etc) ▸ Deployable output requires no execution or interpreting by the web server.

Slide 5

Slide 5

WHAT ARE STATIC SITES GOOD FOR?

Slide 6

Slide 6

ANY SITE THAT DOESN'T NEED DYNAMIC CONTENT. James Titcumb @asgrim WHAT ARE STATIC SITES GOOD FOR?

Slide 7

Slide 7

I’M A FAN OF THEM WHERE A SITE CONTENT CHANGES RARELY (QUARTERLY / ANNUALLY PERHAPS)… BROCHUREWARE TYPE SITES. Steve Kirtley @stevekirtley WHAT ARE STATIC SITES GOOD FOR?

Slide 8

Slide 8

THE SECURITY ASPECT IS A BIG PLUS FOR ME. WITH NO SERVER-SIDE SCRIPTING LANGUAGE INVOLVED THE ATTACK SURFACE DROPS THROUGH THE FLOOR. Nev Stokes @nevstokes WHAT ARE STATIC SITES GOOD FOR?

Slide 9

Slide 9

THEY'RE HANDY WHEN YOU WANT THE HOSTING SETUP TO BE AS MINIMAL AS POSSIBLE (FROM GITHUB PAGES, OR AN S3 BUCKET, FOR INSTANCE). Tom Hazledine @thomashazledine WHAT ARE STATIC SITES GOOD FOR?

Slide 10

Slide 10

[FOR OUR PROJECT WE WERE] ALSO THINKING ABOUT LONGEVITY. HTML, CSS, JAVASCRIPT FOREVER! Sally Lait @sallylait WHAT ARE STATIC SITES GOOD FOR?

Slide 11

Slide 11

STATIC SITE GENERATORS AND PHP ADVANTAGES OF STATIC SITES ▸ Minimal and inexpensive hosting requirements ▸ Introduces no additional attack surfaces ▸ Fast - low user wait times, so better UX ▸ Simple and therefore long-lasting

Slide 12

Slide 12

WHAT ABOUT, YOU KNOW, ACTUAL FUNCTIONALITY?

Slide 13

Slide 13

STATIC SITE GENERATORS AND PHP FUNCTIONAL THINGS THAT REAL WEBSITES ACTUALLY HAVE ▸ Contact forms ▸ Content search ▸ Commenting ▸ Authentication ▸ A/B, multivariate, bucket testing

Slide 14

Slide 14

“SERVERLESS” (SOMEONE ELSE’S SERVER)

Slide 15

Slide 15

Slide 16

Slide 16

JAVASCRIPT APIS MISPLACED SENSE OF 
 NOSTALGIA

Slide 17

Slide 17

STATIC SITE GENERATORS AND PHP SERVERLESS YOUR HTML SITE THE CLOUD

Slide 18

Slide 18

STATIC SITE GENERATORS AND PHP THE 1990S YOUR HTML SITE CGI-BIN

Slide 19

Slide 19

STATIC SITE GENERATORS AND PHP ‘SERVERLESS’ THINGS WE ALREADY DO ▸ Analytics ▸ Mailing list sign-ups ▸ Social interactions, like, share etc ▸ Payment gateway integration (e.g. Stripe.js)

Slide 20

Slide 20

SERVERLESS ARCHITECTURE DANCES TO THE MELODY INSTEAD OF THE BEAT. @drewm STATIC SITE GENERATORS AND PHP

Slide 21

Slide 21

STATIC SITE GENERATORS AND PHP ADVANTAGES OF STATIC SITES ▸ Minimal and inexpensive hosting requirements ▸ Introduces no additional attack surfaces ▸ Fast - low user wait times, so better UX ▸ Simple and therefore long-lasting

Slide 22

Slide 22

STATIC SITE GENERATORS AND PHP ADVANTAGES OF STATIC SITES ▸ Minimal and inexpensive hosting requirements 
 Proprietary platform and/or third-party APIs (+ cost) ▸ Introduces no additional attack surfaces 
 Multiple additional attack surfaces, out of your control ▸ Fast - low user wait times, so better UX 
 Slow pages chock full of JavaScript ▸ Simple and therefore long-lasting 
 Brittle with multiple potential points of failure

Slide 23

Slide 23

KNOW WHAT YOU’RE GETTING INTO.

Slide 24

Slide 24

STATIC SITE GENERATORS AND PHP STATIC SITES ARE GREAT ▸ Be conscious of when you need a genuinely static site ▸ Keep weighing the pros & cons ▸ It’s really easy to fixate on the pros and end up in Con City

Slide 25

Slide 25

HOW CAN I DO THIS IN THE PHP?

Slide 26

Slide 26

SCULPIN sculpin.io Symfony-based 
 Twig templates 
 Composer install

Slide 27

Slide 27

JIGSAW jigsaw.tighten.co Laravel-based 
 Blade templates 
 Composer install

Slide 28

Slide 28

COUSCOUS couscous.io Designed for documentation sites Twig templates 
 Composer install

Slide 29

Slide 29

IN CONCLUSION

Slide 30

Slide 30

STATIC SITE GENERATORS AND PHP IN CONCLUSION ▸ Static sites are good ▸ Serverless is cgi-bin for hipsters ▸ SSGs for PHP are a thing ▸ I’ve been @drewm ▸ You’ve been lovely, thanks!