phpmyadmin configuration to quicky login to phpmyadmin as mysql root user, use this only for development server which is not publicly available

copy config.sample.inc.php to config.inc.php

change configuration options at the beginning to:

/*
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = true;

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';

// do not group tables
$cfg['NavigationTreeEnableGrouping'] = false;

 

run those commands to setup permissions for both apache2 and cli commands,

so you can run cache:clear command or remove app/cache/dev or app/cache/prod directories without subsequent problems with permission denied errors

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs

 

 

How to search key value pair in multidimensional array? In other words search for subset of multidimensional, multilevel array by key and value pair.

This is solution to this problem, notice that in $arr[1] there is multidimensional array, and is also returned in output of search.

<?php

$arr = array(
    0 => array(
        'id' => 0,
        'name' => "cat 1"
    ),
    1 => array(
            array(
                'id' => 1,
                'name' => "cat 1"
            )
    )
,
    2 => array(
        'id' => 2,
        'name' => "cat 2"
    )
);

$arrIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr));

foreach ($arrIterator as $arrIteratorItem) {

    $subArray = $arrIterator->getSubIterator();

    if (isset($subArray['name']) && $subArray['name'] === 'cat 1') {
        $outputArray[] = iterator_to_array($subArray);
    }
}

print_r($outputArray);

output of print_r :

Array
(
    [0] => Array
        (
            [id] => 0
            [name] => cat 1
        )

    [1] => Array
        (
            [id] => 1
            [name] => cat 1
        )

)

BTW as you can see in first code snippet, it do not include closing ?> tag. As you can know closing PHP tag is optional. And if do not necessary you can and should not include it. This is because after closing PHP tag there could be empty white space character that will make problems with sessions. Ie. “headers already send” type of errors.

Sources: