Category Archives: PHP

Laravel whoops output – How to hide. env passwords

As of Laravel 5.5.13, there’s a new feature that allows you to blacklist certain variables in config/app.php under the key debug_blacklist.

When an exception is thrown, whoops will mask these values with asterisks * for each character.

To activate this feature, add the next lines inside config/app.php

    'debug_blacklist' => [
        '_ENV' => [
        '_SERVER' => [
        '_POST' => [

Save the file and clear the config cache with

php artisan config:clear

After this, all keys added inside debug_blacklist array will be replaced with asterisks (************)

Quick Laravel – Part 1

Laravel 5.x requires PHP version 5.5.9+. Also, in case you want to use database (sqlite or mysql), install Sqlite3, Mysql or PostgreSQL server.

Install composer with

curl -sS | php
sudo mv composer.phar /usr/local/bin/composer

Install Laravel (option 1)

composer create-project laravel/laravel laravel-test

Instal Laravel (option 2)

composer global require "laravel/installer=~1.1"

Add the following to .bashrc file

export PATH="~/.composer/vendor/bin:$PATH"

at the end of the file then in terminal type

source ~/.bashrc

and verify that $PATH variable contains the full path to laravel executable.

Then create new Laravel project with

laravel new laravel-test

Test installation

cd laravel-test
php -S localhost:8888 -t public

and open http://localhost:8888 in your web browser

SSH2 extension for PHP on CentOS 6

Before we can build and install ssh2 extension, we’ll need a few packages

yum install gcc php-devel php-pear libssh2 libssh2-devel make

Install the extension via pecl

pecl install -f ssh2

On CentOS, PHP will not load extension automatically. To “fix” this, create ssh2.ini file inside /etc/php.d/ and add


Restart apache (service httpd restart) and test PHP with

php -m | grep ssh2

As response, you should get ssh2.

CentOS 5 Call to undefined function sqlite_escape_string()

If you’re using PHP 5.2.x on RHEL/CentoOS and you received error

PHP Fatal error:  Call to undefined function sqlite_escape_string()

don’t worry. The reason for this is the missing sqlite extension which is not included in RHEL/Fedora/CentOS php packages by default.

To fix this issue, you can include it manually

tar xzvf php-5.2.XX.tar.gz
cd php-5.2.XX/ext/sqlite/
make install
echo >> /etc/php.d/sqlite.ini
service httpd restart

Replace XX with your PHP version (check the php version with “php -v”)

Extra Packages for Enterprise Linux – EPEL HowTo

EPEL (Extra Packages for Enterprise Linux) is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages that complement the Fedora-based Red Hat Enterprise Linux (RHEL) and its compatible spinoffs, such as CentOS and Scientific Linux.

Adding EPEL repo is very easy:

rpm -Uvh epel-release-6-8.noarch.rpm

From unknown reason for me, CentOS 6.x goes without php-mcrypt package and it is impossible to install this rpm from base repos. Some apps will complain about this and one of the solutions is to install this rpm from EPEL repo… After you added EPEL repo, type:

yum install php-mcrypt

Zen coding in Aptana

Zen Coding is a set of plug-ins for text editors that allow for high-speed coding and editing in HTML, XML, XSL, and other structured code formats.

To install ZC plugin,

  • click Help -> Install new software
  • in the “work with” field, type this repo address:
  • Press “Add…”, give it a name and press OK.

Zen coding should appear on the software list, under “uncategorised”.

You can install it as you’d install any other plugin.

Tested & confirmed to be working with:

Aptana 3.x

PHP Fatal error: Class ‘DOMDocument’ not found in …

This morning I found the next errors inside the web server log.

PHP Warning: include(DOMDocument.php) [<a href="function.include">function.include</a>]: failed to open stream: No such file or directory in ......
PHP Warning: include() [<a href="function.include">function.include</a>]: Failed opening 'DOMDocument.php' for inclusion (include_path='.....
PHP Fatal error: Class 'DOMDocument' not found in .....

The solution for this problem is to install the missing php-xml rpm.

yum install php-xml

How to install phpshield loaders

PHPShield is an PHP encoder application that is used to protect the PHP code which is an excellent option for encoding your PHP files if you don’t require any time limiting, IP/Domain locking or other licensing features which are available in phpSHIED older brother SourceGuardian.

This post will cover installing phpSHIELD on a Linux server (RH based distros). You must have root access to your server which means if you have shared hosting account, you won’t be able to install phpSHIELD. In this case, you’ll need to contact your hosting provider and to ask them about phpshield loades.

The first step is to find out which PHP version do you have with

# php -v

and you will get something like

PHP 5.1.6 (cli) (built: Feb  2 2012 18:25:25)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

Then download loaders from this link (according to your platform) and unpack them on your local drive.

The next step is to upload encoded files and visit app link. You should get something like

PHP script /var/www/html/myApp/index.php is protected by phpSHIELD and requires the phpSHIELD loader phpshield.5.1.lin. The phpSHIELD loader has not been installed, or is not installed correctly. Please visit the phpSHIELD php encoder site to download required loader.

Note: The files in my case were encoded by older PHPShield (3.1). The new version (8.x) will probably have the same message where phpshield.5.1.lin will be replaced with ixed.5.1.lin

I suppose that your server is a 64bit which means that PHP will load modules from /usr/lib64/php/modules dir.

Copy downloaded ixed.5.1.lin file inside /usr/lib64/php/modules dir.

Then open /etc/php.ini and add the next line at the end of the file


Save the changes and restart apache (service httpd restart)

UTF-8 with MySQL and PDO

If you are using PDO (PHP Data Objects) and you’re having problems with utf-8, try to add PDO::MYSQL_ATTR_INIT_COMMAND option inside PDO definition like I wrote below.

$db = new PDO(