Laravel last query raw output

<?php
 
dd(\DB::getQueryLog());

php enable errors

<?php
 
error_reporting(-1);
ini_set('display_errors', 'On');

php when pass by reference

1. Objects should be passed by reference always, arrays and scalars are passed by value.
2. If you are working on a very large array and plan on modifying it inside a function, you actually should use a reference to prevent it from getting copied, which can seriously decrease performance or even exhaust your memory limit.
3. If it is avoidable though (that is small arrays or scalar values), I’d always use functional-style approach with no side-effects, because as soon as you pass something by reference, you can never be sure what passed variable may hold after the function call, which sometimes can lead to nasty and hard-to-find bugs.
4. Scalar values should never be passed by reference, because the performance impact can not be that big as to justify the loss of transparency in your code.

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.";