How to output custom HTTP body contents with CakePHP 3.4? Echoing causes “Unable to emit headers” error

Controllers should never echo data! Echoing data can lead to all kinds of problems, from the data not being recognized in the test environment, to headers not being able to be sent, and even data being cut off. Doing it that way was already wrong in CakePHP 2.x, even though it might have worked in … Read more

Php-intl installation on XAMPP

These below steps helped me, Just in case if you are using OSX Steps from http://www.phpzce.com/blog/view/15/installing-intl-package-on-your-mac-with-xampp Check which php path is set i.e. root$: which php If you are using xampp on your mac it should be /Applications/XAMPP/xamppfiles/bin/php but if its /usr/bin/php you need to change your OSx php root$: PATH=”/Applications/XAMPP/xamppfiles/bin:${PATH}” Install icu4c root$: brew … Read more

“[notice] child pid XXXX exit signal Segmentation fault (11)” in apache error.log [closed]

Attach gdb to one of the httpd child processes and reload or continue working and wait for a crash and then look at the backtrace. Do something like this: $ ps -ef|grep httpd 0 681 1 0 10:38pm ?? 0:00.45 /Applications/MAMP/Library/bin/httpd -k start 501 690 681 0 10:38pm ?? 0:00.02 /Applications/MAMP/Library/bin/httpd -k start … Now … Read more

How to limit contained associations per record/group?

What you are looking for, is a solution to the greatest-n-per-group problem. You didn’t mention any specific RDBMS, but nonetheless see also http://dev.mysql.com/doc/refman/5.6/en/example-maximum-column-group-row.html A library solution For those who are a little bit adventurous, I’ve developed some custom associations that transparently integrate into the ORM layer, and allow for basic limit per group for hasMany … Read more

CakePHP 3.0 installation: intl extension missing from system

I faced the same problem today. You need to enable the intl PHP extension in your PHP configuration (.ini). Solution Xampp (Windows) Open /xampp/php/php.ini Change ;extension=php_intl.dll to extension=php_intl.dll (remove the semicolon) Copy all the /xampp/php/ic*.dll files to /xampp/apache/bin Restart apache in the Xampp control panel Solution Linux (thanks to Annamalai Somasundaram) Install the php5-intl extension … Read more

How to filter by conditions for associated models?

Use Query::matching() or Query::innerJoinWith() When querying from the Contacts table, then what you are looking for is Query::matching() or Query::innerJoinWith(), not (only) Query::contain(). Note that innerJoinWith() is usually preferred in order to avoid problems with strict grouping, as matching() will add the fields of the association to the select list, which can cause problems as … Read more