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...
IT Tips
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'=>...
Custom Location of cups-pdf denied by apparmor
Apr 25 09:31:23 tgn-vm-wms01 kernel: audit: type=1400 audit(1650879083.060:80): apparmor="DENIED" operation="mknod" profile="/usr/lib/cups/backend/cups-pdf" name="/var/www/tgn/webroot/files/PDF/Test_Page-job_12.pdf" pid=80336 comm="gs" requested_mask="c"...
CakePHP 4 from a sub directory
I have a default Nginx install on Ubuntu 22.04 LTS inside a Docker Container using I want /var/www/html to remain as the root but a CakePHP 4 app to be served as follows requests to hostname.example.com as served from /var/www/html requests to...
Where in the Middlewares should CORS Middleware be placed in CakePHP?
Answer: Before RoutingMiddleware EventManager::instance()->on('Server.buildMiddleware', function ($event, $middleware) { try { $middleware->insertBefore(RoutingMiddleware::class, new CorsMiddleware()); } catch (\LogicException $exception) { $middleware->add(new...
Client Apache Reverse Proxy Cake Token Auth
I have a reverse proxy that protects backend with basic auth client -> basic auth reverse proxy -> token auth cakephp backend curl -v \ -H 'Authorization: Basic base64_encoded_user_pass_here' \ -H 'Authorization: Token cakephptokenhere' \...
CentOS httpd taking 90 seconds to restart – systemctl restart httpd
The fix: systemctl kill httpd systemctl start httpd The problem: systemctl restart httpd ### wait for 90 seconds... too long
Using 7z cli to create chunked PST
# create a folder to hold the chunks mkdir archive651 # run the command to split the pst into 1GB chunks and plonk them in the folder 7z a -v1g archive651\archive651 "archive 651.pst" Just discovered that azcopy is nowhere near as good as the AWS utilities that upload...
Replacing my OnePlus 3T with a OnePlus 9
I purchased a OnePlus 3T from Kogan July 2018 It has been a good phone but recently I noticed it was starting to get slow. So I started to think about replacing it However the decision to replace it was forced on me. While on holidays recently in Tasmania I fumbled my...
Use the Azure metadata Service to query the Public IP Address of VM
curl -s -H Metadata:true http://169.254.169.254/metadata/instance?api-version=2021-02-01 | jq -r '.network.interface | .[] | .ipv4.ipAddress | .[] | .publicIpAddress' #output 13.70.193.102
Get Your External IP Address
curl -s https://ipinfo.io/json | jq curl http://checkip.amazonaws.com
Free Web Application Firewall from CloudFlare
So I just saw a Youtube video about a DDOS attack and saw an article online about Cloudflare offering a free Web Application Firewall. What does a WAF do? You transfer for your DNS Zone management to Cloudflare It changes the IP Address of your website so that it...
Cannot connect to Debug Terminal in Unifi Controller
TLDR; Try a Different Browser If you click on a Unifi devices IP address in the Cloud Key or Unifi Controller or click on "Open terminal" under tools in the device pane it should open a browser based cli I just tried to connect using Firefox 97.0.1 and got "Connection...
Updating WordPress / Divi to PHP8.1.x on Ubuntu 20.04
So have installed PHP8.1 from ondrej PPA sudo add-apt-repository ppa:ondrej/php Install PHP8.1 sudo apt install php8.1-fpm sudo apt install php8.1 sudo apt install php8.1-intl sudo apt install php8.1-mbstring sudo apt install php8.1-mysql sudo apt install php8.1-xml...
Install nodejs in docker container and auto detect architecture
Installing node binary package from https://nodejs.org/en/download/ I use Docker on my x86_64 Ubuntu Workstation and Macbook Pro M1 aarm64 so Dockerfiles need to be multi-arch This Dockerfile snippet detects the architecture we are running in and sets the correct...