CakePHP 2 Form and trying to POST to it using curl This is what I am trying to duplicate with curl -----------------------------1993502965129257581246610166 Content-Disposition: form-data; name="_method" POST -----------------------------1993502965129257581246610166...
cakephp
CakePHP/Queue WorkerListener Example Class
This is an example of implementing a WorkerListener class for the new CakePHP/Queue plugin as mentioned here => https://book.cakephp.org/queue/1/en/index.html#worker-events Config array // ... 'Queue' => [ 'default' => [ // A DSN for your configured backend. default:...
Encrypt / Decrypt the columns of your CakePHP 4 DB
https://stackoverflow.com/a/32261210/9230077 The above is a good solution, but it needed updating to work with CakePHP 4 I have updated the above as below to encrypt a database field with a base64 encoded encrypted string The base64 encoding is so it can save in a...
CakePHP 4 Time Zones
CakePHP 4 incorrect test table names created from Fixtures
Leaving this here as I just spent an annoying hour trying to figure out why my tests were failing. CakePHP Version: 4.2.5 Platform and Target: Ubuntu 20.04, Apache/2.4.41 (Ubuntu), Mysql 8.0.23-0ubuntu0.20.04.1, PHPUnit 8.5.15 What I was doing I was running CakePHP 4...
How to copy values from one column to another using CakePHP 4 Query Builder
I want to change the name of a column in my database and to do that I have to create a migration and drop a table The query I want to run is UPDATE pallets SET production_date = print_date; Seem so simple in SQL but to do it in CakePHP 4 took some finding Copy data...
CakePHP 4 has Deprecated File & Folder
So recently my code editor has been putting a line through File because it is going to removed in CakePHP 5 So here is an example of code that uses the deprecated methods and the suggested SplFileObject Using File public function createTempFile($print_content,...
CakePHP 4 $this->request->referer() not working in production
Just had a situation where I couldn't get a redirect to work. My CakePHP app is in an Apache enabled docker container behind an nginx reverse proxy $this->redirect($this->request->referer()); The above simply refused to work in my development environment it worked...
Getting multiple duplicate Modelless Forms on the same page working with CakePHP 4
I have the need of creating a page with multiple forms on it that have 'copies' and 'printer_id' fields on them. Each form has, or might need separate validation values. My first attempts ended up with the other form with the same field names getting the values from...
Format validationsErrors
A recursive function that takes a validation error array and return a string with all the different errors concatenated into a formatted string Further to my previous posting https://toggen.com.au/it-tips/cakephp-2-displaying-validation-errors This function will walk...
Embed Create React App SPA into CakePHP 3.8.x view
Some small changes from the old CRA version 2.x the asset-manifest.json now has an entrypoints key // view code src/Template/Assigned/schedule_edit.ctp <?php foreach ($css as $style) : ?> <?= $this->Html->css('/react' . $style, [ 'block' => true ]); ?> <?php...
CakePHP 2.x Reducing Database Column Sizes by changing from TEXT to VARCHAR Column Types
I was using a TEXT database field for some text settings and found that it uses 64kb of data SELECT name, char_length(comment)/1024 FROM settings; Checking the field size with the above query I found that the largest content was 0.6660 kb. So I had specified a...
CakePHP – SQLSTATE[HY000] [2002] Permission denied
Just saw this error and usually this is due to having a misconfiguration in the database connection options. But I am running Fedora 25 with seLinux enabled by default. First to test if it's seLinux causing an issue If...
CakePHP 2 – Dynamically Globally Changing the Database Connection
Dynamically Globally Changing the Database Connection in CakePHP 2.x I use this code in app/Model/AppModel.php to dynamically change my database environment in CakePHP 2.x depending where it is running <?php //app/Model/AppModel.php App::uses('Model', 'Model');...
Making Weird Grunting Noises with CakePHP 3 & Twitter Bootstrap
This is how I got grunt running with the twbs/bootstrap plugin to automatically copy the CSS, JS and Fonts into my CakePHP 3 development environment. I did this on MacBookPro OSX 10.11.5. But this applies to Linux too. If anyone has better suggestions as to how this...
CakePHP POST Failing
I was just trying to submit about 10 x 15 records... and found that cakephp was failing with a validation error. Found out it was due to the following in the php error log. [09-Jun-2016 19:16:22 Australia/Melbourne] PHP Warning: Unknown: Input variables exceeded...
CakePHP 3 – Escape to the Global Namespace
This code in CakePHP 3: <?php $date = '31/01/1973'; $ymd = DateTime::createFromFormat('!d/m/Y', $date)->format('Y-m-d'); Causes this error Error: Class 'App\Controller\DateTime' not found This code fixes it: <?php $date = '31/01/1973'; $ymd =...
CakePHP 2 Slightly Better Looking than Default Pagination
Just trying to make my pagination in CakePHP 2 better looking. I added the first and last links but still had a radius on my previous and next links which looked odd and my 'last >>' link had a square end too. So a bit ugly really. Following is an example of...