cakephp code example
Example 1: cakephp life cycle
Example 2: setup cakephp
1. Add .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
2. Add Permission tmp, Vendor, Webroot
- Window Set permisson
- Linux Set chmod -R 777
Example 3: cakephp 4 change layout view in a method
$this->viewBuilder()->setLayout('ajax');
Example 4: multiple OR cakephp
$conditions = array();
$conditions = array(
'OR' => array(
array(
'MemberRole.school_id' => array(),
'MemberRole.role_id' => $role,
),
array(
'MemberRole.school_id' => array(),
'MemberRole.role_id' => Environment::read('role.register'),
),
array(
'MemberRole.school_id' => $school_id,
'MemberRole.role_id' => Environment::read('role.register'),
),
array(
'MemberRole.school_id' => $school_id,
'MemberRole.role_id' => $role
),
),
);