php

  • wp_insert_post fires every hook the editor fires

    An import loop calling wp_insert_post() is doing everything a human clicking Publish does: revisions, term counting, ping status, and every plugin listening on save_post. For ten posts that…

  • Time a block of code in PHP

  • Fixtures that build objects, not rows

    A fixture written as SQL or as an array of columns encodes the schema into every test, so a column rename breaks two hundred tests that have nothing…

  • The OPcache file cache, for when shared memory resets

    OPcache keeps compiled bytecode in shared memory, which is empty after every restart — so the first requests following a deploy or an FPM reload each pay full…

  • session_start() takes its options inline

    Session settings had to be applied with ini_set() before session_start(), in the right order, from somewhere that ran early enough — which is why so many applications have…

  • composer outdated separates safe from breaking

    composer show –latest lists everything with a newer version, which on a mature project is forty lines that all look equally urgent and are not. The –minor-only list…

  • Scalar type declarations are a per-file decision

    PHP 7 added scalar type hints and then made them optional in a way that surprises people: without declare(strict_types=1) the engine coerces, so a function typed int happily…

  • composer why explains a version you did not choose

    When Composer installs an old version of something you never asked for, the answer is always a transitive constraint — and reading composer.lock to find which package imposed…

  • Upgrading a production application to PHP 7

    Twice the throughput and half the memory, for a migration that is mostly deletions — plus the four behaviour changes nobody puts in the upgrade notes.

  • Model events fire on the model, not on the query builder

    Eloquent fires saving, created, deleted and the rest when a model instance is saved. A mass update or delete goes straight to the query builder and fires nothing…