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
2
votes
1 answer
Cakephp 3 - reusable code for Table Entities
I have some code, that I need to apply for multiple Tables' Entities
similar to the example here
http://book.cakephp.org/3.0/en/orm/entities.html#accessors-mutators
protected function _setTitle($title)
{
// code to make re-usable
…

dav
- 8,931
- 15
- 76
- 140
2
votes
1 answer
Best practice translate CakePHP 3.x __ Function
Using the __('') function is really nice. But I am wondering how can I translate whole paragraphs with links and highlighting in it. For example:
= __('Bla bla text in german bla bla ')?> Account text bla bla…

Isengo
- 2,004
- 3
- 21
- 43
2
votes
1 answer
Cakephp 3 _matching, how format results data
My query looks like:
$test = $this->Producers->find()
->hydrate(true)
->select(['Producers.id','Producers.name', 'Products.id', 'Products.name']);
$test->matching(
'Products.Categories', function ($q) {
…

Maciej Chyra
- 53
- 1
- 8
2
votes
1 answer
How to execute a Shell method in a Controller?
I am using a cakephp3 plugin to manage a mail queue to send newsletter (Lorenzo Cakephp Email Queue). It works fine, but I need to use a Shell method with the bake command to send the newsletter.
It is not a problem with a cron job, but I would…

wyllyjon
- 505
- 1
- 5
- 20
2
votes
1 answer
How to unitTest CakePHP 3.x Controller Actions that require HTTP Basic Authentication?
I'am trying to authenticate a user by adding the PHP_AUTH_USER and PHP_AUTH_PW to the $_ENV-Variable, but this has no affect. I'am using the following configuration with memory-Storage:
$this->loadComponent('Auth', [
'authenticate' => [
…

Niklas
- 95
- 1
- 9
2
votes
1 answer
In CakePHP3 migrations (or Phinx), how to use utf8mb4 charset?
Creating MySQL table or adding columns with CakePHP3 migrations, charset is set to UTF8.
Is there the way to set charset utf8mb4?
(and, i found this issue... https://github.com/robmorgan/phinx/issues/74)

Hideki Kinjyo
- 59
- 4
2
votes
3 answers
CakePHP change format in a list input
I send from a controller this query:
$tareas = $this->Tests->Tareas->find('list', [
'limit' => 200,
'keyField' => 'id',
'valueField' => 'Fecha'
]);
The valueField 'Fecha' is a date in my database.
So…

Alejandro Pascual Montenegro
- 51
- 1
- 7
2
votes
2 answers
CakePHP 3 - Sharing controller level logic between admin/non-admin controllers
With the separation of admin and non admin at the controller level (which I much prefer to using 1.3's admin prefix) I am finding I'm duplicating too much code. Is there a way to share controller logic between the two controllers? I don't feel what…

Westy
- 93
- 7
2
votes
0 answers
paginate an union in Cakephp 3
I'm trying to paginate a union in cakephp 3. I have already found and read How do you modify a UNION query in CakePHP 3?, but am probably too new to cakephp to understand properly what is meant by "use a custom finder". I have read the relevant…

fpet
- 73
- 8
2
votes
2 answers
How to find entities with common parent using matching() in CakePHP?
I need to find all articles having the same author as a given list of articles
Here is my custom finder method:
public function findSimilar(Query $query, array $options)
{
if (empty($options['idList'])) {
throw new…

Benjamin Tamasi
- 662
- 7
- 18
2
votes
1 answer
CakePHP 3.x UnitTest "Base table or view not found"
I get an Error-Message in a UnitTest in CakePHP 3.2 and the official documentation doesn't help me here anymore. I think the error has something todo with the SQL-Joins I try to use.
The Error-Message is the following:
`1)…

Niklas
- 95
- 1
- 9
2
votes
1 answer
CakePHP3.2: I can't delete dependent associated
I should make a big mistake as I already done this several times, but I really don't understand why deleting associated only partially works:
My entities are declared like that:
class SitemessagesTable extends Table {
public function…

fralbo
- 2,534
- 4
- 41
- 73
2
votes
1 answer
CakePHP 3 defaultConnectionName in plugin model doesn't work
I create a portal based on the framework cakephp 3 and admin panel made as a plugin to separate the files from the rest. The tables, which will cover only the admin panel I put in separately created database 'admin'.
I have correctly configured…

Rochu
- 108
- 6
2
votes
1 answer
How can I get all the modified fields before saving the editing in cake php?
Using the
$entity->errors(); //is returning all errors.
to find changes before upgrading
There is something like
$entity = $this->Controller->patchEntity($entity , $this->request->data);
echo $entity->diff (); // how?

Paulo Alexandre Chaves Pinto
- 189
- 1
- 17
2
votes
0 answers
Failed sending email with cakephp 3.1 | stream_socket_client()
I have a problem with CakePHP 3.1 on my virtual server.
When I try to send e-mails on localhost, everything works perfect, no errors, no warnings.
However when I try to send e-mails on vserver, I receive the following error:
2016-01-06 11:07:33…

ratze90
- 33
- 4