ReflectionException: Class Tests\Unit\Symfony\Component\HttpKernel\Exception\NotFoundHttpException does not exist

Running unit tests in Laravel, I was getting this error:

ReflectionException: Class Tests\Unit\Symfony\Component\HttpKernel\Exception\NotFoundHttpException does not exist

The issue was missing root backslash, make sure you have expected exception like:
$this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class);

 

Upgrading to PHP 7.0 on Ubuntu 14

I upgraded PHP to version 7.0 on Ubuntu box. Running php -v on shell would show it as version 7.0. But Apache was still using PHP 5.6. I tried various methods to update settings for Apache but nothing worked until I issued following commands:


sudo a2dismod php5.6
sudo a2enmod php7.0
sudo service apache2 restart

Source: PHP 7.0 (and 5.6) on Ubuntu | LornaJane

Filter Some Keys in Multi-dimensional Arrays in PHP

  /**
    * Cleans up multi-dimensional arrays.
    * 1st dimension is a simple index
    * 2nd dimension includes the desired keys
    *
    * @param mixed $array
    * @param mixed $keysToInclude
    */
    public function cleanUpArray($array, $keysToInclude){
        $returnArray = array();
        $i = 0;
        foreach($array as $item){

            foreach($keysToInclude as $key){
                $returnArray[$i][$key] = $item[$key];
            }
            $i++;
        }

        return $returnArray;
    }

JSON_ERROR_CTRL_CHAR

I was using mcrypt to encrypt json_encoded data.

On other side, mycrypt was able to decrpyt data but json_decode was not working. It would throw JSON_ERROR_CTRL_CHAR error.

However, without mcrypt, json_decode worked flawlessly.

After some trial and error, I found that applying trim function after decrypting data would let me use json_decode without any issues.

CodeIgniter Out Of Memory Error

Query Saving is a feature of CI’s database class that stores the results of every query in memory until the controller is finished executing. As it turns out, in version 1.6.0, the ability to turn this off was added. The addition of the save_queries variable is listed in the Change Log, but as of the latest release of 2.0.0 last week, it still hasn’t made the documentation.

$this->db->save_queries = FALSE;

via Undocumented CodeIgniter | Green Egg Media.

One thing to note is that disabling save_query would disable some other Database class functions like last_query(). So it is not just used by profiler.