Questions about 4.x branch of the CakePHP MVC framework. Use this tag in combination with the general [cakephp] tag. If your question applies to CakePHP more generally, use only the [cakephp] tag.
Questions tagged [cakephp-4.x]
511 questions
0
votes
0 answers
CAKEDC/USERS.User Plugin. Always get "You are not authorized to access that location." after visit Home Page
Good evening,
I'm working with cakephp4 an CakeDc/Users plugin 9.0.5. I'm have register option deactivated.
Everything is working ok but I have an Issue for non superuser users. I'm getthing the error You are not authorized to access that location.…

Gonzalo
- 43
- 6
0
votes
1 answer
Cakephp I18n setLocale doesn't change language
I have a Cakephp 4 project internationalization used to work but today I tried it changing the PC and it didn't change the language and doesn't give any error.
I have this methid to change language in AppController:
public function…

Iria
- 9
- 4
0
votes
1 answer
How to disable CakePHP4 DebugKit creating the huge tmp/debug_kit.sqlite file
I've developed an app with CakePHP 4.4.11. In production environment, I set debug to false in app_local.php.
'debug' => filter_var(env('DEBUG', false), FILTER_VALIDATE_BOOLEAN),
The app is working fine as expected, however, I noticed the…

mmrn
- 249
- 2
- 8
- 18
0
votes
1 answer
CakePhp 4: I configured I18n internationalization but the site is still in english
Good night's community,
I trying to use localization tools of cakephp 4 without success.
First, I have my pot and mo files in cake_root/resources/locales/es_AR.
In my app.php file I have:
Finally, in my AppController I have...
Everything looks OK…

Gonzalo
- 43
- 6
0
votes
1 answer
How do I fix the beforeSave method for cakephp4?
I am following the tutorial on https://book.cakephp.org/4/en/tutorials-and-examples/cms/articles-controller.html and after adding this function:
public function beforeSave(EventInterface $event, $entity, $options)
{
if ($entity->isNew() &&…

Wesley Au
- 21
- 2
0
votes
1 answer
Vendor bake plugin function definition changes
A colleague is cloning a repo and getting the following error when running bake commands through our own plugin:
PHP Fatal error: Declaration of OurPlugin\Command\ModelCommand::findBelongsTo(Cake\ORM\Table $model, array $associations): array must…

TechFanDan
- 3,329
- 6
- 46
- 89
0
votes
1 answer
Display a msg when a user authenticates more than 5 times a day with cakephp 3.x or 4
I want to know if a user has logged in 5 times or more in the same day and show him a msg afterwards
this is my login function:
public function login()
{
if($this->request->is('post')){
$user = $this->Auth->identify();
…

Rihab
- 1
- 1
0
votes
1 answer
Config file did not return an array
Currently upgrading a project from CakePHP2 to CakePHP4 and I received the error Config file "tmi.php" did not return an array.
This is how I'm importing it into bootstrap.php:
try {
Configure::config('default', new PhpConfig());
…

Austin Poulson
- 685
- 7
- 22
0
votes
2 answers
Always eager load association in CakePHP 4
In my CakePHP 4 project, I have two models with a one-to-many relationship between them:

mrodo
- 565
- 5
- 21
0
votes
0 answers
Extend behavior for specific class in CakePHP 4
In my project, I have defined a VisibilityBehavior that I apply to some of my models.

mrodo
- 565
- 5
- 21
0
votes
0 answers
Can't save various entities in cakephp 4.4
I have a belongsto association between StatesxDays and three tables: Users, Groups, Nets, when I do $user = $this->StatesxDays->Users->newEntities($this->request->getData()); it doesn't put the StatesxDays entities, this is the code for addUser…

Matías de Anquin
- 1
- 1
0
votes
1 answer
CakePhp 4 add "Content-Type: text/html" when I try to show a PDF
I trying to show a PDF inline but I get binary code instead. The mock that I show below works OK in a simple php file in webroot but show binary code from an entity template.

Gonzalo
- 43
- 6
0
votes
0 answers
How to get custom variables when using a custom Email Transport with CakePHP 4, for sending bulk mails with Postmark
I want to send bulk mail (newsletters) with the Postmark Batch API. Postmark Batch API requires me to combine up to 500 mails per request.
Therefor I have created an custom NewslettersTransport.php which is handeling the API call and setting up the…

DvL
- 47
- 5
0
votes
0 answers
Invalid conversion while trying to save array
PHP: 8.1
CakePHP: 4.4.
Postgres: 13
Problem: While generating entity Block, after setting data, the val property is always set to null
Table definition
create table blocks
(
id integer generated always as identity
val …

Boorsuk
- 291
- 1
- 10
0
votes
1 answer
Limiting amount of statements sent to database
Is there a way to combine/pool many insert or update statements to send them once to the database?
Until I figure out a network latency issue, I'm curious to see if it's possible to send an insert or update statement containing many rows from…

TechFanDan
- 3,329
- 6
- 46
- 89