Questions about 3.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-3.x]
963 questions
3
votes
2 answers
Where to define table/entity classes when using the standalone CakePHP ORM?
I am using the standalone sub-project 'cakephp-ORM' of cakephp
CakePHP-orm.
I cannot find in the documentation where on the filesystem to define tables and entities.
It is explained how to create tables, but not where to save them to. Will the table…

marius
- 1,118
- 1
- 18
- 38
3
votes
0 answers
Deprecation of TableRegistry::get()
I'd like to ask what are your thought on deprecation of the TableRegistry::get() static call in CakePHP 3.6?
In my opinion it was not a good idea.
First of all, using LocatorAwareTrait is wrong on many levels. Most important, using traits in such…

mbryja
- 61
- 1
- 8
3
votes
1 answer
Update entity on save rather than insert
In my code I am trying to create a lock entity when a controller function is called. Once I create the new entity I save this in the database. Once the controller function finishes the rest of its logic I update the lock entity before I return the…

user2860682
- 89
- 2
- 7
3
votes
1 answer
CakePHP3 After removal of afterFind, where to check if query result empty?
Before i checked in the afterFind callback if the result of the find is empty.
Since the callback was removed in latest versions, where would be the place to check that from a behavior?
Im not realy sure if that is what i need. My use case is, i…

Tolga
- 262
- 5
- 16
3
votes
1 answer
How do I access SESSIONs in CakePHP's app.php?
I am using CakePHP 3.3
I am trying to set session timeout's value and other settings in app.php to a value stored in config database table.
I tried using the line below but it's just stoping execution of the webpage.
$myConfigs =…

Keyur Padalia
- 2,077
- 3
- 28
- 55
3
votes
2 answers
Cakephp 3 same model multiple pagination?
I had been working on a project and stuck in a problem where a view needs two pagination on same model with different conditions in Cakephp 3.
For eg. opened and closed support tickets listing on the same view.
The following is my code. Can someone…

Sehdev
- 5,486
- 3
- 11
- 34
3
votes
1 answer
How to compare two fields/columns in a condition?
I am having a hard time trying to figure out how to get a sub-query working.
Imagine I have:
$schools
->select($this->Schools)
->select([
'pupilcount' => $this->Pupils
->find()
…

Sammaye
- 43,242
- 7
- 104
- 146
3
votes
1 answer
CakePHP 3.4 how to insert on a belongs to and has many relationship
On cakePHP 3.4, i have 3 tables with a belongs to and has many relationship: Ingredients, Products and IngredientsProducts:
class IngredientsTable extends Table
{
public function initialize(array $config)
{
// Use through option…

Tzi
- 35
- 1
- 4
3
votes
1 answer
Converting array to string for date format in CakePHP 3.x
In my form, when I submit it, I send a notification email that is populated with the form inputs. One these inputs is called date.
When I submit the form, it is submitted in the format of an array as follows:
[
'year' => 'yyyy',
'month' =>…

mistaq
- 375
- 1
- 8
- 29
3
votes
0 answers
CakePHP 3 - Query Matching Condition depending on joinTable result data
I'm trying to create a query that return companies based on a joinTable result
I have 3 tables:
Companies, Units and Users
Companies belongsTo Units
Units hasMany Companies
Users belongsToMany Units - ['joinTable' => 'users_units']
Users…

PauloSalvatore
- 31
- 2
3
votes
2 answers
How to change error response structure for JSON request Cakephp 3
In my router.php i have enabled the json extension with Routing File Extensions like this
Router::prefix('api', function (RouteBuilder $routes) {
$routes->extensions(['json']);
$routes->fallbacks('DashedRoute');
});
All is working good.…

Aman Rawat
- 2,625
- 1
- 25
- 40
3
votes
2 answers
Authorize users based on roles in CakePHP 3
I would like to authorize users based on few roles. All visitors should be able to reach method show. So I wrote in AppController:
public function beforeFilter(Event $event) {
$this->Auth->allow(['show']);
}
It works.
In initialize() method of…

nexequ
- 321
- 5
- 16
3
votes
1 answer
need to use concat with list of find method in cakephp 3.x
i am using cakephp 3.1. in that i need to use concat the firstname and lastname with space using list of find method..
I tried below code it return with semi columns but i need space instead of semi columns.
Code:
$query = $articles->find('list',…

Kamlesh Gupta
- 505
- 3
- 17
3
votes
1 answer
Digest Authentification under CakePHP 3
I am trying to create a digest authentication using the Authentification component under Cakephp 3.1 and I have encountered a problem. I am using the code below and I have the HTTP-Authentication popup that pops up right after entering the correct…

Mickaël Pastor
- 33
- 2
3
votes
2 answers
Cakephp 3 i18n not working
I have cake 3 fresh installation.
I have a simple po file in this location src/Locale/de_DE/default.po with the following content.
msgid "test"
msgstr "test in german"
On my home page template file I have simple
I need to…

dav
- 8,931
- 15
- 76
- 140