Front Line PHP – Building modern web applications with PHP 8

The folks over at Spatie are at it again, this time with Front Line PHP. An ebook on cutting edge tactics in PHP 8, accompanied by videos and practical examples. The videos covering the new additions to PHP 8 are free to watch, and should give you an idea of what you can expect. At …

Convert Guzzle requests to curl commands with namshi/cuzzle

The other day the namshi/cuzzle PHP pacakge came in really handy. This library let’s you dump a Guzzle request to a cURL command for debug and log purposes This way I could test some things on the CLI, and easily share these tests with all my colleagues, including those without PHP installed. use Namshi\Cuzzle\Formatter\CurlFormatter; use …

Legacy to Laravel: How to Modernize an Aging PHP Application

The folks at Tighten: In this post, I’ll present some strategies we use at Tighten to convert legacy apps to Laravel gradually over time, without needing to perform a full rewrite. Whether you’re upgrading from an old framework or moving to a framework for the first time, following these steps will let you start benefitting …

PHP: Convert a Geolocation (Latitude / Longitude Coordinates) to a Timezone identifier

Part of a PHP project I’m working contains a list of sites/buildings. For each site/building we monitor some data, for example its energy usage. We decided that we wanted to generate a daily/weekly/monthly reports of the data, by aggregating the datapoints. As our sites/buildings are spread across the globe – and thus timezones – we …

PHP 8 in 8 Code Blocks

Brent has been following the PHP releases and featured up close. In this post he highlights 8 of the features that will make it into PHP 8 Attributes (aka Annotations) Union types The static return type The just-in-time Compiler throw in Expressions Non-capturing catches Trailing commas in parameter lists New str_* functions As a bonus …

PHPUnit: A Security Risk?

The author of PHPUnit was a bit surprised when he received a mail stating that PHPUnit was a security risk and hackers could remotely execute PHP code through a file named eval-stdin.php that ships used to ship with PHPUnit. // eval-stdin.php eval ('?>'. \file_get_contents('php://input')); Even though the eval-stdin.php file itself indeed was vulnerable, it never …

Sharing PHP-CS-Fixer Rules Across Projects and Teams

Tim MacDonald shares a way to sharing PHP-CS-Fixer rules across your projects. It involves in setting up on repo/package that contains the rules and a little helper class that takes in a PhpCsFixer\Finder instance (along with optional extra rules). <?php namespace TiMacDonald; use PhpCsFixer\Config; use PhpCsFixer\Finder; function styles(Finder $finder, array $rules = []): Config { …

Composer Inline Aliases: Fake a PHP Package Version by Aliasing a Specific Commit to it

Great tip by Mattias: TIL: you can fake package versions in composer using the "as" alias. Useful to force install certain versions while keeping other dependencies in check! 👍https://t.co/VzmMRCCoR5 — Mattias Geniar (@mattiasgeniar) April 16, 2020 You can alias directly when requiring a package: composer require monolog/monolog:”dev-bugfix as 1.0.x-dev” Surely comes in handy when locally …

Laravel Valet not picking up php.ini changes, a fix

If you have Laravel Valet not picking up php.ini changes, try this: .@laravelphp Valet wasn't detecting any of the changes I made to php.ini. Restarting brew services and restarting Valet had no effect. Turns out the valet.sock file was being persisted and somehow caching settings. `rm ~/.config/valet/valet.sock` solved my problem! 🙌🏽 — Jose Soto (@JoseCanHelp) …