Categories
Uncategorized

Search Tweet by Author

my search terms (from:mike_hasarms)
Categories
Workflow

Installing Lando / Docker for WSL2

I’m working on this for the Windows host. The official Lando docs are out of date, referring to Ubuntu 18 and Hyerdrive which I read is not well maintained.

I found this blog post that hopefully is the way forward.

Categories
WordPress

Theming WordPress in 2022

Historically I’ve used the Underscores starter theme with Sass when building a custom theme. Now I’m interested in incorporating Blocks, Patterns, and also being able to use Tailwind.

I did just build a site with _tw which is a Tailwind focused fork of Underscores. It has potential but was a bit difficult to override some of the default behaviours and styling.

The default WordPress Twenty Twenty Two theme doesn’t strike me too well. If you want to build a site that looks like it, it’s not bad, but I found the customization got awkward very quickly.

I think I’m still keen on the ACF approach, but could certainly use Blocks in standard page area. I just don’t want to build the outer pages with them. The ACF PHP API for creating custom blocks is also very handy unless I ever get some in-depth React knowledge to do it with JS.

So if I were to build a new website now I’d probably consider:

  • Another test of _tw with the latest version, using ACF for custom sections and mostly limiting myself to non-layout blocks.
  • Investigating other Tailwind starters
  • Just regular old Underscores once more. Forget the last six years?
Categories
DevOps

WSL2

I setup a sample Laravel app with Sail. Works, but I have to disable local Apache and MySQL to free up their ports. Should be able to configure the virtual host to use different host ports, but I couldn’t figure out the syntax.

Twitter pointed out that the slowness is due to file system syncing.

I have to investigate this for Laravel, and URL mapping. Would I have to setup PHP, Nginx etc directly in the VM? Then I’m losing the benefit of Sail configuring that for me.

I’m probably missing something obvious.

Categories
Workflow

ExifTool

I needed to modify the meta data (title) of a PDF. This tool was pretty good! Cheers Phil Harvey.

https://exiftool.org/

Categories
PHP Workflow

Switching local PHP versions with Homebrew

At the time of writing PHP 8.1 is the default, and I have 7.4 and 8.0 installed.

To swap them around link/unlink and then stop and start the appropriate Homebrew service.

Linking changes CLI version; starting the service affects the version Nginx connects to.

You may also want to change the binary that Tinkerwell loads.

Odd Bits

The syntax to link unlink PHP 8.1 (default) are different to the other two. I would not have a clue why.

When you stop a PHP service, sometimes a “fallback” one automatically starts. It might not be the one you want, so you have to stop it and start the one you need.

PHP 8.1

brew unlink php && brew link php

Other versions

brew link --overwrite --force php@7.4
// or 
brew link --overwrite --force php@8.0

Starting the Homebrew service

brew services list
brew services stop php@8.0 
brew services start php
brew services start php@7.4    etc...
Categories
DevOps Workflow

Upgrading to PHP8.0 Locally

Added PHP8.0 with Homebrew. I’m using the shivammathur/homebrew-php tap as recommended in Brent’s post.

Steps

  • brew tap shivammathur/php
  • brew install shivammathur/php/php@8.0
    That seemed to immediately link it. CLI reported 8.0 after that ran.
  • Nginx automatically used it via php-fpm once I restarted Nginx and the PHP service (and Redis)
nginx-restart //(custom alias I have set in .zshrc)
brew services restart php
brew services restart redis

Switching Versions

I think this will just be a matter of brew linking the desired version (if already installed), and restarting php/nginx.

brew link --overwrite --force php@8.0

I’m not totally sure what the old 7.4 is called as far as Brew is concerned. It was the default back when I installed it, so maybe it’s just php , or possibly php@7.4

(A similar thing will probably happen now that PHP 8.1 is the default. I installed PHP 8.0 when it was, so it’s just php . Is it now php@8.0 ?)

Categories
Workflow

Git Track new branch

Commit changes to new local branch, then:

git push -u origin new_branch_name

Categories
Laravel

Laravel Validation – All Errors for One Field

Laravel’s message bag as the $errors->all() method to get all errors, across all fields.

Single error for a field in Blade helper:

@error('the_field') {{ $message }} @enderror

All errors for one field

$errors->get('the_field');
Categories
Uncategorized

Remove SSL from certbot

When you point a domain away from a server with Let’s Encrypt and Nginx tries to restart after SSL renewal it will fail. The domain IP link is broken, so you’ll get expired certs on unrelated sites.

To remove the SSL with certbot:

cd /opt/certbot
./certbot-auto certificates   //list existing certs
./certbot-auto delete --cert-name example.com