PHPNews

Slim4-empty: minimal Slim 4 starting point

To simplify creating a new Slim 4 project, I've created slim4-empty which does this for me. To use it: $ composer create-project akrabat/slim4-empty my-new-project and you're done! The my-new-project directory is created and contains Slim 4 along with a minimally viable public/index.php to get …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday September 11, 2019


Receiving input into a Slim 4 application

A Slim 4 (and Slim 3) application receives data from three places: Any query parameters on the URL (the key-value pairs after the ? ) The HTTP message's body (usually for POST and PUT) messages Parameters in the URL (such as the 3 in https://example.com/users/3 Within the application, these are …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday September 4, 2019


Automatically mounting a network drive on Mac

I have so many photos that I can't store them all on my hard drive and keep them on my NAS. While on my home network, it would be convenient to automatically mount the NAS folder onto my Mac as I keep forgetting before I open Lightroom. Usually I would use automount to do this, but Lightroom cannot see automounted …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday August 28, 2019


A first look at Slim 4

With Slim 4 we have continued the tradition of allowing you to use the framework in the way that best fits you and your project. You can create a Slim application entirely in a single file suitable for prototyping through to a few files for a simple web hook or serverless action all the way to fully-decoupled …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday August 21, 2019


Displaying exif information in WordPress posts

After discovering that WordPress modifies img tags when rendering a page, it crossed my mind that I could display exif information underneath each image on my new photography blog . The basic process is applicable to any manipulation of the content that you would want to do before it is displayed. To do this, we …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday August 14, 2019


Images and WordPress

My new WordPress project has multiple photographs per post and as I wanted them to work in an efficient manner for multiple screen resolutions. The secret to this is the srcset and sizes attributes on the img tag. It turns out that WordPress will create multiple sized thumbnails when you upload an image. It …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday August 7, 2019


Developing WordPress sites with Docker

I recently set up a new WordPress based website and local Docker -based development environment. This post documents what I did, so that I can do it again next time! As I'm not in the WordPress world, many things are strange to me and I'm indebted to Jenny Wong for pointing me in the right direction on numerous …

Continue reading »

Written by Rob Allen - - Aggregated on Thursday August 1, 2019


Setting title and caption with exiftool

I recently needed to change the title and caption of some photos, so I turned to exiftool as it's the Swiss Army knife of image metadata. It's a lovely tool with many options, so I wrote a script to make it easy and while I was there, used read to prompt me for the info to set. This is the script: …

Continue reading »

Written by Rob Allen - - Aggregated on Monday July 29, 2019


Creating virtual environments with Pyenv

rst2pdf is a Python 2 application that we're making compatible with Python 3. When developing Python applications, I've found it useful to be able to switch python versions easily and also set up clean environments to work in. To do this, I currently use pyenv . This is how I set it up: Install Pyenv On my …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday July 17, 2019


Running PHP applications on Azure App Engine

Azure App Service is a way to host your web application in a container without having to think about the server. It's the same PaaS concept as AWS Elastic Beanstalk and supports all the main web programming languages. It also supports Windows and Linux OS containers. I have a client that is moving an on-premises …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday July 3, 2019


Step debugging sphinx-build in PyCharm

I've been trying to solve an issue with the rst2pdf Sphinx extension which allows you to use rst2pdf to create a PDF of your Sphinx documentation rather than using Sphinx's default pdfTeX builder. In order to understand what was happening, I really wanted to inspect variable at certain stages of the process, …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday June 26, 2019


PHP Architect: Serverless PHP With Bref, Part 2

Part two of my article on using Serverless PHP using Bref has been published! In part one , I introduced Bref as we wrote a simple "Hello World" application. Part follows this up exploring a more complete serverless application, my Project365 website. This S3 hosted static website is build using a serverless …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday June 19, 2019


Keyboard shortcut to Save as PDF on Mac

I regularly print to PDF on my Mac, This is done from the print dialog by selecting Save as PDF from the drop down in the bottom left of the dialog which is a bit of a pain to get using the mouse. I recently discovered that I could create a keyboard shortcut to make this much easier. In System Preferences …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday June 12, 2019


Extracting the base name of a file in Bash

I have a handy bash script that transcodes videos using Don Meton's video_transcoding tools . This script was written in a hurry and one limitation it had was that it re-transcoded any source file even if the output file already existed. The script looked like this: #!/usr/bin/env bash readonly source_dir="${…

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday June 5, 2019


Circular dependencies in AWS SAM Policies

I'm trying to tighten up the policies of my AWS Lambda function so that it only has access to the one S3 bucket that it needed, so I added an S3CrudPolicy with the BucketName referencing the bucket that's defined in the template. The relevant part of template.yaml looks like this: Resources: ImagesBucket…

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday May 29, 2019


My Bref Makefile

In order to use Bref efficiently, I've developed a Makefile so that I don't have to remember all the various commands required. In particular, looking up the correct parameters to sam package & sam deploy is a pain and it's much easier to type make deploy and it all works as I expect. It looks like …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday May 15, 2019


PHP Architect: Serverless PHP With Bref, Part 1

I've written a two-part series on Serverless PHP on AWS Lambda using Matthieu Napoli 's Bref for php[architect] . Part one has been published in the May 2019 issue and if you're not already a subscriber, you should be! If you just want to learn about Bref though, then my introduction to Bref is available …

Continue reading »

Written by Rob Allen - - Aggregated on Thursday May 9, 2019


Slim 4 Cyclomatic Complexity

There's not much wrong with Slim 3 ; lots of people are using it very successfully producing APIs and websites of all kinds. For Slim 4 the main goals have been to support PSR-15, make it easier to use your own PSR-7 implementation, improve error handling and remove assumptions that look magical if you don't know …

Continue reading »

Written by Rob Allen - - Aggregated on Wednesday April 3, 2019