31,616 questions
0
votes
0
answers
67
views
Retrieving values from 2 tables at the same time in CakePHP 3
I'm developing a small module on CakePHP 3 and I'm currently encountering a small problem that I can't seem to solve.
I have two tables: Events and shop_ticket.
Events table:
I store information ...
1
vote
1
answer
59
views
Api Rest in CakePHP: How to return id fields (Bigint) as string and not as INT/BIGINT?
I created a REST API in CakePHP 4.5, and all the ID fields are of type Bigint. Is there a way to force CakePHP to convert these fields to strings before returning the JSON?
There are many fields, and ...
0
votes
0
answers
25
views
CakePHP Bake Error - Association alias is already set
I've just created a new site using CakePHP 5 for the first time (I've used CakePHP 2-4 before). I'm baking the models from my database, but one of them is failing.
My database tables are as follows (...
0
votes
1
answer
54
views
Resource class Administrator does not exist while implementing modeless policy
I'm trying to implement a policy for a model-less controller. The error I keep getting when I access /administrators/import
Resource class Administrator does not exist.
InvalidArgumentException
Here ...
0
votes
0
answers
69
views
Can you get CakePHP 4 to return JSON error responses automatically when writing an API?
CakePHP 4.x
We have an application which consists of a frontend web app (used by customers through a browser) and an API for some backend operations which is integrated with our other systems.
The ...
0
votes
1
answer
48
views
CakePHP 5 Middleware: Authorization check error when using custom middleware
I'm building a web application in CakePHP 5 using the Authentication and Authorization plugins.
My users can be members of multiple clubs through a many-to-many relationship (using a join table). The ...
0
votes
1
answer
35
views
Cake\ORM\Marshaller::_mergeAssociation(): Argument #1 ($original) must be of type Cake\Datasource\EntityInterface|array|null, int given
Full error:
error: [TypeError] Cake\ORM\Marshaller::_mergeAssociation(): Argument #1 ($original) must be of type Cake\Datasource\EntityInterface|array|null,
int given, called in /var/www/vhosts/dpg3....
0
votes
1
answer
68
views
File validation in CakePHP 4
Basically trying to do this https://discourse.cakephp.org/t/validate-uploaded-file-size-through-model/6755/5 in a CakePHP 4.5.9 application.
I have a Model called Whitepapers and with I'm trying to ...
0
votes
0
answers
32
views
Using `StringTemplateTrait` to build templates
I have a helper that defines the time template like this:
protected array $_defaultConfig = [
'templates' => [
` 'time' => '<time{{attrs}}><i class="far fa-clock fa-sm ...
0
votes
0
answers
47
views
Trying to understand PHP Garbage Collection [duplicate]
Forgive my ignorance but I've not played around with PHP's garbage collection before. Specifically, I'm running a CakePHP 5.x Command Script and running into memory exhausted issues.
As a test to see ...
-1
votes
1
answer
24k
views
Datasource class could not be found
i googled this error in many ways but only could find irrelevant messages
i am migrating a cakephp 4.2 PHP application to cakephp 5 and only the 'default' database is usable
in my app_local.php i have ...
0
votes
1
answer
29
views
`save()` with associated `hasMany` record fails composite UNIQUE index on "Duplicate entry"
What I have
ConfigurationsTable hasMany ValuesTable
In return,
ValuesTable belongsTo ConfigurationsTable
ValuesTable belongsTo ParametersTable
Each value can belong to a unique combination of a ...
1
vote
0
answers
46
views
having problems since recreating my database
I have a controller on my Api folder named CrudsController and I have this function. what I don't understand is this is properly working before I had issues with my database that I had to recreate. ...
1
vote
1
answer
61
views
CakePHP connect to Google SQL Proxy Container
For starters, I have a docker container running for "cloud-sql-connectors/cloud-sql-proxy:2.14.3" and it has credentials and appears to have started and is running fine.
2025-01-29 12:31:44 ...
1
vote
1
answer
41
views
Where do you store configuration profiles for CakePHP 4 Mailer?
I'm writing an app in CakePHP 4.5 which sends emails.
I'm trying to avoid writing this all over my code
$mailer = new Mailer('default');
$mailer->setEmailFormat('both')
->setFrom(['me@example....
0
votes
0
answers
29
views
CakePHP 5 patchentity camelCase mapping
I am receiving data with camelCase fields from a PUT request, but my entity requires the data to be in snake_case as per CakePHP 5 conventions.
Should I convert the fields to snake_case, or should I ...
0
votes
0
answers
36
views
How can I use pagination in DataTable used in cakePHP2
I’m trying to use serverSide: true with DataTables in an older CakePHP project (CakePHP Version: 2.x), but I’m running into issues. When I enable the server-side option, the table doesn’t load ...
0
votes
1
answer
133
views
CakePHP stores 2024-12-30 as 2025-12-30 in MariaDB, but 2024-12-29 works correctly
I’m working on a CakePHP application where I save dates into a MariaDB database. The absent_date field is of type DATE. However, I’ve encountered a peculiar issue:
When I save 2024-12-30, it gets ...
0
votes
0
answers
48
views
How to build a query to update a record using CakePHP 4.4 and Slim-4 and MariaDB
The back story on this request is I am using SlimFramwork 4 Skeleton. I have been running it for a couple of years now. I need to update a record in the database. I have this method
namespace App\...
0
votes
0
answers
39
views
Nested routes prefixes in CakePHP
In my routes.php I currently have this:
$routes->prefix('Api', function (RouteBuilder $routes) use ($apiCache) {
$routes->registerMiddleware('apiCache', $apiCache);
$routes-&...
0
votes
0
answers
57
views
PDO Exception Unknown column when removing column from data table
I am currently working on removing deprecated columns from my database. After dropping a specific column, I encountered the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column
'...
1
vote
1
answer
23
views
Make CakePHP querybuilder wrap a subquery in parentheses
How do I wrap a subquery in extra parentheses?
$sub = new \Cake\Database\Query();
$sub
->select('b.value')
->from(['b' => 'other_table'])
->where(['b.key' => 'fancy_cars'])
;
$...
0
votes
1
answer
70
views
Submitting Modelless Form with FormHelper in cakePHP5
I am using cakePHP5 and I'm having trouble submitting post values with FormHelper and it's a modelless form. Here is the code .
C:\xampp\htdocs\cake3app\templates\Hello\index.php
<!DOCTYPE html>
...
0
votes
1
answer
83
views
Vscode extension for cakephp import?
For instance I have the following statement,
TableRegistry::getTableLocator()->get('Users')->find()
Intelephense is showing, Undefined type 'App\Controller\Api\TableRegistry'.intelephense(P1009)
...
0
votes
0
answers
33
views
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'processing.org_dress_id' in 'on clause' in CakePHP
$emp_detail = $this->fetchTable('EmpDetails')
->find(contain: ['Processing.ProcessStage',
'Processing.OrgDress.PrimaryC',
...
0
votes
1
answer
72
views
Aliases for table fields in CakePHP4
In my DB I have a table page_content with a column which is a reserved MySQL 8 word, row.
Due to constraints mandated by my hosting system, I need to rename the column to something that isn't a ...
0
votes
1
answer
74
views
How to use `distinct()` in a query in Cakephp5?
I'm looking for the way to avoid duplicates in a query in Cakephp5.
Here is my table rubriques :
id | ... | model | ...
======================
1 | ... | CustomRubriques | ...
2 | ... | ...
0
votes
1
answer
48
views
How to select mulitple options in multiple select select menu in cakephp
This is my code for the multiple select menu in my cakephp application:
<td><?= $this->Form->select('clothCutting['.$color.'][mtr_str]', ['23'=>'23', '67'=>'67', '24'=>'24'], ['...
0
votes
1
answer
101
views
CakePHP 5 with latest CakeDC Users plugin
Went through all the setup and installation, got all my apis and connecting to google. However it's throwing and error message. So I debugged it some and at a lose or brain dead at the moment.
Traced ...
0
votes
1
answer
46
views
Unable to save data using HasOne association in Cakephp 4
I have tried to join two tables using hasOne association in my cakephp app
There are two tables users and admin. In both tables the id is primary key. i have linked the mobile field of admin to the ...
0
votes
1
answer
111
views
CakePHP 5: how to get total number of records retrieved with pagination
I'm migrating from cakephp 4 to 5.x, and in an API I need to return the pagination data.
In cakephp 4.x
$paging = $this->request->getAttribute("paging");
$paginacao = [];
foreach ($...
-1
votes
1
answer
32
views
Timestamp in database is European (16:35), but in CakePHP application is UTC (14:35)
Working on development of application, using CakePHP 5 framework.
Problem I have, is that it shows different timestamp for same record in application and in database.
To prevent that, I made changes ...
0
votes
1
answer
115
views
Paginating with sort and direction
Cakephp Version: 5.0.10
Hi,
Tickets Controller - The Process
The page is initially loaded and I initialise the limit from the database and store in a setter with:
$this->setLimit($user->...
1
vote
1
answer
106
views
Why getting this error message submitting a cakePHP file upload form data?
I added enctype="multipart/form-data" In the form with the input fields for files or images.
Please, can you help me review my codes and why I have this error message issue below on trying ...
0
votes
1
answer
176
views
CakePHP giving error 302 (due to sessions?) after migrating a website
I have to migrate CakePHP 1.3.0 website which uses PHP 5.6 version, in this case from CPanel to Plesk, I tried using Plesk Migrator extension, for those who don't know it, it connects to source server ...
1
vote
0
answers
46
views
CakePHP 4 JSON response gives phpstan error
According to the CakePHP 4 docs
// If you want a json response
$response = $response->withType('application/json')
->withStringBody(json_encode(['Foo' => 'bar']));
If you run phpstan on ...
-1
votes
1
answer
79
views
Getting " The request to `/users/login` did not apply any authorization checks." while using Authorization in cakePHP
I am learning to implement authorization cakephp 5 using this documentation https://book.cakephp.org/5/en/tutorials-and-examples/cms/authorization.html
But i'm getting "The request to /users/...
0
votes
1
answer
53
views
Accessing data in another table without a relationship in a query
CakePHP Version 4.4.11
Hi,
Introduction
In text I would like to do the following:
visit the lead archives table and select records with the account_id.
visit the contacts table and select records ...
0
votes
0
answers
47
views
Calling component in a Cell using CakePHP 4
How is a component called in a cell? Or is that still not advisable? Ex. CakePHP 3 Component in a Cell
I have the following code in my cell:
$coordinatorDiscussions->formatResults(function (\Cake\...
0
votes
0
answers
59
views
Intermittent TABLE ALREADY EXISTS database error
In CakePHP 4.3.3 with SQLite I use a temporary table which I refresh by deleting and re-creating. Occasionally from the CREATE statement I get an error that the table already exists, despite that my ...
0
votes
0
answers
29
views
how to automatically load a custom view in a plugin in cakephp?
Here I developed a nano system to publish thoughts in a diary, very simple, but functional for the need. The content is in a Json structure and there would be a need to change the aesthetics of the ...
0
votes
0
answers
43
views
beforeSave is not firing when saving entity
im trying to use Cakephp version 3.10 to fire a beforeSave event but it's not doing anything.
This is the only Controller / Table that dont wa
Controller
public function edit($id = null)
{
$...
1
vote
0
answers
36
views
Unable to use both route options and a nested resource callback in CakePHP 5.x
I'm trying to use nested restful routing by CakePHP 5, but it seems impossible to use both route options as an array, and nested resource definition as a callback. The following example does not work ...
0
votes
0
answers
98
views
Cakephp 5 Form Helper Displaying validation messages before sending the form
I'm doing the cakephp 5 cms tutorial and I want to use Boostrap 5 form validation.
But I see that the Form Helper does not render the div with error messages for the field’s required and notBlank ...
0
votes
0
answers
145
views
Adding authentication component to versionned API
URL being accessed: /api/v1/requests - using Cake - Setup routing to support versioned API controllers? as inspiration
The goal is to load my own custom authentication, however, it's partially loading ...
0
votes
0
answers
46
views
CakePHP5 - How can I migrate findAuth from CakePHP3
I'm about to migrate my old CakePHP3 App to 5.
It is quite difficult.
I try to entend the Auth Identity which is actually limited tu users table field with associated data.
In 3 i use FindAuth, but it ...
0
votes
0
answers
56
views
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'location_id' cannot be null
Check the below code I have converted this from web code , almost similar code is working on web now when I converted it into api to integrate it into app, I am facing issue: "error": &...
2
votes
1
answer
124
views
How to Add SSL Certificate to Outdated CakePHP Website with Apple FileMaker Server?
I'm trying to update an outdated CakePHP website and add an SSL certificate. The website is integrated with an Apple FileMaker server. What steps should I follow to achieve this? Any specific ...
0
votes
0
answers
59
views
ckfinder 3 config file and CakePHP 5
How to insert CakePHP5 session into ckfinder config file? Are there any restrictions? The problem is that within the ckfinder config file I cannot retrieve the global session variable.
I tried the ...
1
vote
0
answers
67
views
CakePHP in Subdirectoy on Nginx Reverse Proxy to Docker Running Apache
I have nginx running as a reverse proxy and I am trying to load my CakePHP site on the docker container in a subdirectory. The docker container is running Apache. I do not want the subdirectory in the ...