Tag: CakePHP3

  • CakePHP 3+ .htaccess for troublesome servers

    The Ideal .htaccess for CakePHP, with File Compression and Expires headers. Enable either mod_gzip or mod_deflate for compression. <IfModule mod_rewrite.c> RewriteEngine On Options +FollowSymLinks RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f # enable symbolic links RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+) index.php [L] </IfModule> <ifModule mod_gzip.c> # mod_gzip_on Yes # mod_gzip_dechunk Yes # mod_gzip_item_include file .(html?|txt|css|js|php|pl|ctp)$ # […]

  • Create SEO Friendly urls with this Slugify PHP Method

    Create SEO Friendly urls with this Slugify PHP Method

    /** * slugify * @param string $str * @return mixed * * Converts nasty URLs to clean, SEO friendly ones */ public function slugify($str) { $clean = preg_replace(“/[^a-zA-Z0-9\/_|+ -]/”, ”, $str); $clean = strtolower(trim($clean, ‘-‘)); $clean = preg_replace(“/[\/_|+ -]+/”, ‘-‘, $clean); return $clean; }  

  • CakePHP3 User Authorisation with Cake Bake

    CakePHP3 User Authorisation with Cake Bake

    Create Users Table: CREATE TABLE IF NOT EXISTS `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(50) DEFAULT NULL, `password` varchar(255) DEFAULT NULL, `role` varchar(20) DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; In Terminal, Cake bake the MVC bin/cake bake model users && bin/cake […]

  • Admin Controller and View with CakePHP3 bake

    Admin Controller and View with CakePHP3 bake

    Example Commands bin/cake bake model pages && bin/cake bake controller –prefix admin pages && bin/cake bake template –prefix admin pages bin/cake bake model settings && bin/cake bake controller –prefix admin settings && bin/cake bake template –prefix admin settings bin/cake bake model articles && bin/cake bake controller –prefix admin articles && bin/cake bake template –prefix admin […]