PHP Unicorn Conference Notes

Submitted by cdmo on 5/5/2017

On May 4th, 2017, I attended the virtual conference PHP Unicorn. There were many excellent presentations from leaders in the PHP development community. This article is a quick write up of my notes on some of the presentations. I'll give a quick take on each session and then cursory notes.

General themes were microservices, loose coupling, service containers/dependency injection.

Working with Webhooks

by @lornajane

I really enjoyed this session. I've done many projects where I've consumed API content and a few projects where I've created API content - but the only experience I have with webhooks to this point is with GitLab. I fire off a build script in Jenkins when a webhook is hit. But this session has me thinking about a shifting paradigm in how internet enabled machines can talk and react with each other...

  • opposite of APIs, reverse direction
  • designing a webhook:
    • responses are in JSON, and are verbose
    • "try to hit the 80% mark, how are most people going to use it?"
  • receiving: don't process the requests (no validation), do simple checks and send a 200
  • "trying to create loose coupling points"
  • PostGRES has great JSON support, MySQL has good and getting better. this where requests can be stored, a simple table. a queue would be even better (RabbitMQ, Beanstalkd, Gearman)
  • ngrok.com for testing webhooks
  • Same as "pubsub" pubsubhubbub
  • Example app: guestbook
  • "Serverless programming"
  • Workers. Long running scripts.
  • When? To notify other systems. 
  • So, it's kind of like an API that "does." Send a machine request to a server and the server does some stuff, sends out notifications to other servers, etc. Webhooks are the next "level" or evolution of API.

Curing the Common Loop

Loved this talk. Is there anything more annoying than a hundred or two lines of nested foreach loops and if conditionals? Good luck writing that. Good luck reading that. Good luck debugging that. Been there. I have already drank the array_* function Kool Aid so I'm already into this stuff, however, the concept of Collections was new to me and very intriguing. Collections improve readability.

by @adamwathan

  • higher order functions: closures, anonymous functions
  • "afford more powerful abstractions"
  • array_map
  • array_filter
  • "replace boilerplate scaffold stuff" with closure/anon function
  • "think in steps"... hmm
  • replace for loops with declarative code
  • "inline temp" to replace temporary variables
  • Curing primitive problem: "Collections"
  •  Collection Pipeline
  • "Outdent your code as much as possible"
  • flatMap
  • reduce
  • many of the comman array+callback procedures have handy shortcuts like sum and flatMap
  • str_replace as an example of how much simpler using built-in functions over looping
  • Collections: tightenco/collect, Knapsack
  • fullstuckradio.com, see michael feathers pod
  • "Refactoring to Collections" book 
  • associative arrays in php are weird, most other languages think of these as objects or dictionaries
  • "constructor from a config file".. 
  • readability over small performance concerns
  • Elixir does not allow loops
  • Ruby is very good with functional programming as well

Zend Expressive Blastoff

by @adamculp

"Blastoff" is right, as in my brain shot out to outerspace. This was a really interesting talk, and a lot. It was a pretty deep dive for a fairly short talk, but you could get the gist of how it worked. Basically this is a light framework like Slim that scaffolds for you in a "non magic" way. This is where PHP is trying to move to. The framework is designed around Actions and pipelines. Would love to try out a project.

  • microservice. php moving away from monolithic frameworks towards collections of microservices that do one thing well.
  • ziadoz/awesome-php
  • Zend Expressive is middleware
  • middleware: allows implementation of input/output - makes your application pieces talk to each other.
  • compare to Slim
  • it's good for single-page sites
  • installer wizard (ZendExpressive Skeleton) asks what ServiceContainer should be installed...
    • What router?
    • What template engine?
    • What error handler? (for development environment)
  • not MVC, but "Response" or "Actions"
  • __invoke
  • rungeekradio.com

Lessons Learned After 10 Years of Testing

by @grmpyprogrammer

This talk was all about espousing pragamatism, or put another "perfect is the enemy of done." Seemed also to be a talk on how we as developers get sucked into pointless discussions about the virtues of various tools or approaches, with a binary perspective (i.e., tool X sucks, use tool Y). We need to let it go. Also, do tests, tests are good. Start slow. Find a mentor.

  • Book reco: Extreme Programming Installed (Kent Beck stuff)
  • tests help you understand the bad decisions you made, if done after the fact 
  • start with fizzbuzz for unit testing entre
  • Software Testing Techniques (book reco)
  • "the desire to prove that you're clever" -- nothing is new. all of this stuff has been figured out. 40 years ago. hubris is the problem. No research done.
  • "chicago style" versus "london style" (mock or real thing)... stop the debate, just pick one.
  • manual testing is sometimes the best solution for testing legacy apps
  • "annotations" not in php, as in python
  • Code Climate - analyzes your code for you and grades it (Scrutinizer is another)

Building Robots With PHP

by @assertchris

This last session was all about hacking/making. So, apparently, you can program to the limits of your imagination and time using PHP, arduinos and related projects (Legos electronics?).

  • hardware: 
    • arduino (c and c++) 
    • tessel (works with javascript)
  • BUT you can use PHP
  • "Firmata" <- there are php client for compiling firmata

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.