21 August 2018
I’ve been experiementing with moving some of the code to Drupal 8, and I’m quite intrigued by a different way that I’ve tried to structure it - building on some of the takeaways from Drupal Dev Days.
16 August 2018
Have you ever needed to have a 'special user' to perform tasks on your Drupal site, such as performing actions based on an API request, or for sending an internal site message?
If you just create a new user, how do you identify that user going forward? Do you hard-code the 'magic' user ID in your custom code? What if the user has a different ID on different environments of your site? You could declare it in each environment’s settings file and retrieve it from there, but what then if you need to do the same on another site? That would mean some duplication of code - and something that could have been abstracted and re-used.
I had to do this recently, and rather than just duplicate the code I decided to make it into it’s own module - which then became two modules.
15 August 2018
Recently I was experiencing an issue on the Drupal 8 website I’m working on, where a small number of users were not able to complete the checkout process and instead got a generic
The site has encountered an unexpected errormessage.
Looking at the log, I was able to see the error being thrown (the customer ID has been redacted):
1 August 2018
Last night was the first meetup of Cardiff’s PHP South Wales user group! It was a great first event, and it was great to meet a lot of new people as well as catch up some familiars within the 36 (according to meetup.com) attendees - including some PHP South West regulars.
19 July 2018
I’ve recently re-watched A Clean PHPUnit Workflow in PHPStorm on Laracasts, where Jeffrey configures PhpStorm to run tests from within the IDE. With Drupal 8 using PHPUnit too, I decided to try and do the same with a local D8 site.
Though because I’m using Docksal for my local development environment which, at least on a Mac, runs Docker containers within a virtual machine, there were some additional steps needed to achieve this and to have the tests run within the Docksal virtual machine and using the correct containers.
28 June 2018
Yesterday evening, I did my first workshop (and I believe, the first workshop) held at the Drupal Bristol user group. The subject was automated testing with PHPUnit in Drupal 8, in preparation for my talk at Drupal Developer Days 2018 next week and to help process some ideas for my testing book.
Here are some details about what we covered, and some of my thoughts in review.
4 June 2018
Within the Docksal documentation for Drupal settings, the example database settings include hard-coded credentials to connect to the Drupal database. For example, within a
settings.phpfile, you could add this:
$databases['default']['default'] = [ 'driver' => 'mysql', 'host' => 'db', 'database' => 'myproject_db', 'username' => 'myproject_user', 'password' => 'myproject_pass', ];
Whilst this is fine, it does mean that there is duplication in the codebase as the database credentials can also be added as environment variations within
.docksal/docksal.env- this is definitely the case if you want to use a custom database name, for example.
Also if one of these values were to change, then Drupal wouldn't be aware of that and would no longer be able to connect to the database.
It also means that the file can’t simply be re-used on another project as it contains project-specific credentials.
We can improve this by using the environment variables within the settings file.
6 May 2018
This week I’ve started writing some custom commands for my Drupal projects that use Docksal, including one to easily run PHPUnit tests in Drupal 8. This is the process of how I created this command.
23 April 2018
This is one of those “there’s probably already a better way to do this” situations, but it worked.
I was having some issues this past weekend where, despite everything working fine locally, a server was showing a “500 Internal Server” after I pushed some changes to a site. In order to bring the site back online, I needed to revert the site files back to the previous version, but as part of a new commit.
12 March 2018
In January, Chris Fidao posted a video to Servers for Hackers showing how to put different PHP applications in different subdirectories and have them serving on different paths with Nginx. I’ve had to do this a few times previously, and it’s great to have this video as a reference.