php

  • Symfony 4 and the bundle that does not exist

    A new project used to arrive with forty megabytes of vendor code and one route. The framework got smaller, and the interesting part is what happens at install…

  • The service provider you always end up writing

    Every service eventually needs the same provider: bind the interfaces, register the client with its credentials, and set up whatever the framework does not do on its own.…

  • Apache mod_php and php-fpm are not the same deployment

    Moving from Apache with mod_php to nginx with php-fpm changes where PHP runs, which user it runs as, and which configuration file it reads — and each of…

  • The dump-server keeps var_dump out of the response

    Dumping from inside a JSON endpoint, a queue worker or a middleware corrupts the output you were trying to inspect, so the debugging tool destroys the thing being…

  • hash_hmac is the one to reach for, not hash

    Signing a payload by hashing the secret and the message together is a construction with known weaknesses, and it keeps getting written because it looks obviously correct. HMAC…

  • Collections lazily, with chunk and cursor

    Model::all() on a table with four hundred thousand rows hydrates four hundred thousand objects and then the process dies, having done nothing. chunkById rather than chunk is the…

  • A macro is how you extend a framework class without extending it

    Adding a method to a collection or a response means subclassing, and subclassing a framework class means every place that constructs one has to know about your subclass.…

  • The Responsable interface removes a controller branch

    A controller returning either a view or JSON depending on the request ends up with the same conditional in every action, and the decision has nothing to do…

  • WooCommerce 3.0 deprecated direct property access

    Reading $product->id or $order->billing_email has worked since the plugin existed, because they were public properties on an object wrapping a post. 3.0 makes them private with a magic…

  • The service container resolves callables too

    The container is usually described in terms of constructor injection, so a method needing one dependency for one call ends up either taking it in the constructor or…