Category:

Redirect HTTP to HTTPS in Cakephp3

If you are building CakePHP application and want to move all traffic to HTTPS you can follow bellow simple steps without making any change in .htaccess  file Step 1. Edit AppController to make change use Cake\Event\Event; Step 2. Load security component public function initialize() { parent::initialize(); $this->loadComponent(‘Security’, [‘blackHoleCallback’ => ‘forceSSL’]); $this->loadComponent(‘RequestHandler’); $this->loadComponent(‘Flash’); $this->loadComponent(‘Cookie’); } Step […]

Continue Reading
Posted On :
Category:

PHP function to generate Slug

Here is simple function to generate slug in php. You can copy paste this function and generate slug by passing string in it. function slugify($text){ // replace non letter or digits by – $text = preg_replace(‘~[^\pL\d]+~u’, ‘-‘, $text); // transliterate $text = iconv(‘utf-8’, ‘us-ascii//TRANSLIT’, $text); // remove unwanted characters $text = preg_replace(‘~[^-\w]+~’, ”, $text); // […]

Continue Reading
Posted On :
Category:

Send email in cakephp 3

If you are working with cakephp 3 and need to send email then this tip help you to send email. Step 1. Go to your app.php and find EmailTransport and add your SMTP details ‘EmailTransport’ => [ ‘default’ => [ ‘className’ => ‘Mail’, // The following keys are used in SMTP transports ‘host’ => ‘My_HOST’, ‘port’ => […]

Continue Reading
Posted On :
Category:

Enable Debug Kit in Cakephp 3

Last updated on May 26th, 2018 at 03:10 pmThis tip helps you enable your CakePHP 3 debug kit follow simple steps to enable your debug kit. Enable Debug Kit in CakePHP 3 Step 1. Open terminal and run following command, before enter below command go to the root directory of your project  composer.phar require –dev cakephp/debug_kit […]

Continue Reading
Posted On :
Category:

Read raw data in PHP

This is very useful tip for those who want to read a raw input data in PHP, In simple word when user send JSON data to server you did not have any key to access that data so you use this kind of techniques to do that <?php $postdata = file_get_contents(“php://input”); $data = json_decode($postdata); echo […]

Continue Reading
Posted On :