git changing master branch

git checkout new-master
git branch -m master old-master
git branch -m new-master master

Laravel db migration commands

php artisan migrate
php artisan migrate:rollback

Generate pdf from jpg files

Use convert utility from ImageMagick package

/usr/bin/convert *.jpg result.pdf

Yii routing SEO friendly route

To make the following url work: http://www.website.com/green-juice
add the following rule to config/web.php

        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'green-juice'=>'green/say',
            ]
        ]

Yii routing enable human readable uri

Edit file config/web.php
Add the following to the ‘components’ array:

    'components' => [
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ]

Apache enable SSL module

1.

ls -ltr /etc/apache2/mods-enabled/ssl.load; ls -ltr /etc/apache2/mods-enabled/ssl.conf

result: not found
2. sudo a2enmod ssl
3.

ls -ltr /etc/apache2/mods-enabled/ssl.load; ls -ltr /etc/apache2/mods-enabled/ssl.conf

result: created

PHP measure execution time

<?php
 
$start = (float) array_sum(explode(' ',microtime()));
// PHP Database Business Logic
$end = (float) array_sum(explode(' ',microtime()));
print "Processing time: ". sprintf("%.4f", ($end-$start))." seconds.";

Image optimize

Run optipng to optimize png files in directory:
for i in `ls`; do optipng -i0 -o7 -zm1-9 $i; done

Run optipng for a single file:
/usr/bin/optipng -i0 -o7 -zm1-9 upload/banner/kaspi132px.png

Run jpegoptim for a single file:
/usr/bin/jpegoptim –strip-all upload/banner/kaspi132px.jpg

Run gifscle for a single file:
/usr/bin/gifsicle -b -O2 upload/banner/kaspi132px.gif

mysql export a single table

mysqldump -u -p db table1 table2 table3

Yii turn debug panel on/off

Edit config/main.php (or config/web.php), add or remove the following code:
$config[‘bootstrap’][] = ‘debug’;
$config[‘modules’][‘debug’] = ‘yii\debug\Module’;