Questions tagged [cakephp-4.x]

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.

511 questions
4
votes
0 answers

Cakephp 4 Url->build with array throws route not found error, but not with string

I'm trying to set up cakephp 4 with prefix routing. In my home.php, I have the following code set up (focusing on the html a href tag under "Serving Ones"):
David Wang
  • 41
  • 3
3
votes
1 answer

How to use AppModel in cakephp4, want to call a method after SAVE query execution on all models

Want to log each save activity of all model table. I used afterSave method in a single model i.e. working fine. Now in place of adding same in all modelTable one by one, I want to write below method in a single file from where all modelTable by…
priti narang
  • 258
  • 4
  • 18
3
votes
3 answers

CakePHP 4 - saving associated data not working with 3 simple tables

I have an application in CakePHP 4 and am having problems saving associated model data. I have read Saving Associated Data in the Cake documentation but it's very unclear how this applies especially in my use-case. The application has 3 tables which…
Andy
  • 5,142
  • 11
  • 58
  • 131
3
votes
1 answer

in cakephp4 how to access a model within a model

How do i access another model within a model in cakephp4.2? The docs on this issue isnt clear to me and i can then run a query on this ? TableRegistry is deprecated now. error Unknown method "getTableLocator" called on App\Model\Table\LessonsTable …
atown99
  • 109
  • 12
3
votes
1 answer

Send Emails with CakePHP 4

I want to send an email with CakePHP 4. In app_local.php i have following entry 'EmailTransport' => [ 'default' => [ 'host' => 'smtp.XXX.de', 'port' => 25, 'username' => null, 'password' => null, …
majamuel
  • 31
  • 4
3
votes
1 answer

CakePHP 4.1.4 - How to create, read and check cookies in the new version of CakePHP

In CakePHP 3.8 the segment of my controller looks like this: // ... public function beforeFilter(Event $event) { // ... $this->Cookie->configKey('guestCookie', [ 'expires' => '+1 days', 'httpOnly' => true, …
user3661042
  • 167
  • 1
  • 13
3
votes
1 answer

CakePHP: upgrade from 3.9.x to 4.0: bin/cake upgrade rector --rules phpunit80 Hangs

I'm upgrading a CakePHP 3 app to CakePHP 4, and following the Upgrade Guide. However, the bin/cake upgrade rector --rules phpunit80 tool hangs. A little background, my app was made mostly in CakePHP 3.6. I upgraded it to 3.7,…
dividedbyzero
  • 181
  • 2
  • 13
3
votes
0 answers

CakePHP version 4 create folder if not exist

I have seen cakephp documentation they have File& Folder class. They declared this class has deprecated. Now mkdir() is it the best way to create folder in cakephp version 4 ? if (!is_dir('path/to/directory')) { mkdir('path/to/directory',…
Niloy Rony
  • 602
  • 1
  • 8
  • 23
3
votes
2 answers

Authentication only for Admin prefix CakePHP 4

Hy guys! I haven’t been using Cake from gen 2 so i am a bit stuck with all the new stuff. I added the Authentication Component to my project and it works fine (login/out/pass hash etc) but i can’t seem to find how to make only the “Admin” prefix to…
Riker
  • 33
  • 4
3
votes
1 answer

How do I force CakePHP 3 and CakePHP 4 to show the deprecation warnings / notices?

What I did Purposefully put $this->primaryKey('id') in my Table class Call ->find('all')->all() on that Table inside Controller What I expected A deprecation notice at the top of my screen since primaryKey() is deprecated. What actually…
2
votes
1 answer

Could not view with composite pK CakePHP4

In cakephp-4.x I could not access Controller's view action for composite primary key table. (http://localhost:8765/invoice-items/view/1) Here are samples of the code created by cake bake: InvoiceItemsTable calss in which the primary key is defined…
SaidbakR
  • 13,303
  • 20
  • 101
  • 195
2
votes
0 answers

Upgrade CakePHP 2.X to 4.X

I'm trying to upgrade CakePHP2.x TO CakePHP4.x, I have WAMP 3.2.3 and Php 7.4. Downloaded CakePHP4.X but the entire directory structure is different between CakePHP2 and 4, if anyone share some idea how I can upgrade, that would be very helpful,…
Rafiq Shaikh
  • 103
  • 1
  • 2
  • 11
2
votes
0 answers

CakePHP 4.x Ajax request with CSV-file

I am developing a responsive user interface in CakePHP 4.x which occasionally uses Ajax requests. My Ajax requests are performing just fine but I am having a lot of trouble incorporating a CSV-file in the request so my controller can handle the…
Tom Dijkema
  • 33
  • 1
  • 5
2
votes
1 answer

In CakePhp 4, how to specify unique constraint validator for multiple fields?

In my database i have this table: table `candidates` ( id, email, department ) And both email and department need to be unique (you can apply for a post in two different departments with the same email but not twice in the same…
NoobieErrors
  • 31
  • 1
  • 2
2
votes
1 answer

CAKEPHP 4: I cannot upload many files at the same time

Goodnight (or good morning), I trying to upload multiple files at the same time. I am following the cookbook instructions to build the solution. I always got first file (not and array of files). Here is my view code...
Gonzalo
  • 43
  • 6
1
2 3
34 35