I recently upgraded to Windows 11 and installed latest Nvidia Game ready driver and am now noticing Google Chrome displays a black screen or switches between that and normal. Can't use Chrome https://youtu.be/OmPFBEDICbY How to work-a-round Google Chrome screen...
James McDonald
Add Xdebug to a Chocolatey Installed PHP
This is my version of PHP. installed with choco install php. Notice no Xdebug php -v PHP 8.1.6 (cli) (built: May 11 2022 08:56:01) (NTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.1.6, Copyright (c) Zend Technologies Goto downloads for xdebug here...
Why does my dd output look different in CakePHP 4
If you have ever wondered why sometimes your cake dd() output looks like this: And then other times looks like this: The reason is that the CakePHP/Repl plugin uses symfony/var-dumper and this package has a version of dd() that loads its own version of dd() so the...
CakePHP 4 policy missing from cake bake command
If you try the bin/cake bake policy command and get "Could not find a task named policy." bin/cake bake policy Could not find a task named `policy`. Make sure CakePHP Authorization is installed and then add the following to src/Application.php public function...
Windows 11 – We have finally reached the Year of Linux on the Desktop
Just upgraded to Windows 11 and my WSL (Windows Subsystem for Linux) instance is visible in Windows Explorer _and_ it has the Penguin logo...
Before you Upgrade to Windows 11
Download and install Veeam agent for Windows Community Edition https://www.veeam.com/agent-for-windows-community-edition.htmlIf the upgrade fails you can roll back and try again later (my desktop that I write this post on was unbootable after the first upgrade and I...
List your VSCode Extensions
Ever wondered what extensions you have installed and want to keep a list? This actually is a good way to audit your currently installed extensions and then weed out the ones you no longer need or don't use code --list-extensions # output...
array_merge vs the + operator
<?php $options = [ 'rootNode' => 'response' ]; // array_merge // the same key appearing later will overwrite echo print_r(array_merge(['rootNode' => 'root'], $options), true); /** * output * * Array * ( * [rootNode] => response * ) */ // + syntax if it already...
CakePHP 4 – Dump A List of Form Templates
In your view somewhere enter <?php dd($this->Form->getTemplates()); ?> Reload the page and then you can view the templates and figure out which template to override in your view. Once you have identified which template is causing an issue then you can override it...
Use a Value Object in your Entity Accessors
Just looking at Laracasts https://laracasts.com/series/whip-monstrous-code-into-shape/episodes/6 and God Object cleanup and found you can return a Value Object which can have multiple methods in the object with allows you to return different formatting or return a...
ZPL SBPL
Zebra Printer Language http://labelary.com/viewer.html The above website has a page where you can enter ZPL and it will render a sample. Very handy for development Sato Barcode Printer Language QZ Tray is a really cool web service you install on Windows, Linux and...
PHP Iterators
Just came across a Youtube talk "Iterators in PHP" by Jake Smith published in 2014 that steps through the many different Iterators and some practical examples. I have reproduced many of the examples Jake used below, running them with PHP 8.1.5 and published the code...
PHP array_map Multiple Arrays
array_map can take multiple arrays. I like how it starts mapping through them starting at the first element of each array all together and then keeps mapping until it completes the largest array. Each argument to the callback function is the current element of the...
CakePHP 4 – Formatting Validation Errors for use with Flash Messages
I've posted about this before but I think this approach is entirely less complicated Validation errors in CakePHP come in an array similar to the following: $errors = [ 'asn_number' => [ '_empty' => 'ASN cannot be blank', ], 'their_po' => [ '_empty' => 'Their PO...
CakePHP 4 – Rendering an XML view to a variable
Rendering XML to a variable using CakePHP's XmlView class Learnings Instantiating and using ViewBuilderYou don't need ->set() if you pass the data to ->build()You can move XML creation into its own class to clean your controller action up and use it elsewhere in...
Build Complex LIKE Query with CakePHP Query Builder
How to create this MySQL query with CakePHP 4? SET @search = '9233' COLLATE utf8mb4_general_ci; SELECT * FROM 100pbc_new.addresses WHERE trading_partner LIKE CONCAT('%', @search, '%') OR dc_code LIKE CONCAT('%', @search, '%') OR dc_name LIKE CONCAT('%', @search, '%')...
How to get the Google Chrome PDF Viewer to Display Document Page Sizes in Metric
I am in Melbourne Australia and we use metric page sizes. The default display units for the embedded Google Chrome PDF Viewer is inches. How to set Google Chrome to display document properties in Metric Click the three vertical dots menuChoose settingsEnter language...
Chrome file download – Failed Network error
Just had a situation with sending a file to a browser with POST request and it kept erroring with "Failed - Network error" <?php // post request $barcodefile = 'barcode.pdf'; return $response->withFile(TMP . '$barcodefile, ['download' => true, 'name'=>...