.htaccess for cakephp

The answer is that there are 3 different .htaccess files: /var/www/app/webroot/.htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule> /var/www/app/.htaccess <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] </IfModule> /var/www/.htaccess <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] </IfModule> It’s … Read more

What is the equivalent to getLastInsertId() in Cakephp?

CakePHP has two methods for getting the last inserted id: Model::getLastInsertID() and Model::getInsertID(). Actually these methods are identical so it really doesn’t matter which method you use. echo $this->ModelName->getInsertID(); echo $this->ModelName->getLastInsertID(); This methods can be found in cake/libs/model/model.php on line 2768

CakePHP does not use my models

It’s not possible to give a directly-working answer because: There’s nothing wrong with the code in the question. That probably means you aren’t running your own code at all. Given that the only answer that can be given is advice, the only class that matters for the example in the question is Owner. Check filenames … Read more

Request Entity Too Large PHP

post_max_size and upload_max_filesize are PHP.ini settings. You can set them either directly in PHP.ini or via ini_set. I don’t know if this can be set with some Cake-internal tools as well. However, the error could also be caused by a set limit of the RequestBodyLength in Apache (assuming you are running under Apache).

Why are date/time values interpreted incorrectly when patching/saving?

Date/time values are being casted/parsed in a locale aware fashion Update: this is the default behavior with the CakePHP application template versions prior to 3.2.5. As of 3.2.5 locale parsing is not enabled by default anymore, which will make the date/time marshalling logic expect a default format of Y-m-d H:i:s instead. In the marshalling process, … Read more

CakePHP 3.0 -> Between find condition

Expressions Between expression are supported out of the box, however they only support the first case without additional fiddling: $Query = $Table ->find() ->where(function($exp) { return $exp->between(‘start_date’, ‘2014-01-01’, ‘2014-12-32’, ‘date’); }); If you’d wanted to handle the second case via the between method, then you’d have to pass all values as expressions, which can easily … Read more

CakePHP 2.0 – How to make custom error pages?

Try this: /app/Config/core.php Exception render need to set as an AppExceptionRender. Example: Configure::write(‘Exception’, array( ‘handler’ => ‘ErrorHandler::handleException’, ‘renderer’ => ‘AppExceptionRenderer’, ‘log’ => true )); /app/Controller/ErrorsController.php class ErrorsController extends AppController { public $name=”Errors”; public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow(‘error404’); } public function error404() { //$this->layout=”default”; } } /app/Lib/Error/AppExceptionRenderer.php App::uses(‘ExceptionRenderer’, ‘Error’); class AppExceptionRenderer extends ExceptionRenderer { public … Read more