Category Archives: PHP



Today I decided to write about some Design Patters I’m currently studying for my future reference and I hope it’ll be helpful for you too.

Each post on this post series will be based on books, websites and my own code. I’ll show each external reference I’ll use.

To make it simple I’ll use ClassLoader from Symfony 2 Framework (in a composer dependency, installed easy as “composer install” command)

Source code will be available on

These are the patterns I’m intending to write about:

- Specification
- Strategy
- Decorator
- Chain of Responsibility
- Facade
- Abstract Factory
- Factory Method
- Template Method
- Adapter
- Bridge
- Composite
- Proxy
- Mediator
- Observer
- Visitor

Install Oracle Client on Ubuntu (PHP)

Download Instant Client on:
- oracle-instantclient11.2-basic-
- oracle-instantclient11.2-devel-

Install alien to convert to rmp to deb package:

sudo apt-get install alien

Convert Packages:

sudo alien oracle-instantclient11.2-basic-
sudo alien oracle-instantclient11.2-devel-

Install client:

sudo dpkg -i oracle*.deb

Install Lib for PHP:

sudo pecl install oci8
sudo apt-get install libaio1


Add ”” to your php.ini

show full var_dump

Just update xdebug.ini file

xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1


Catch SoapClient Exception

If you can’t get SoapClient exception if WSDL cant be loaded (PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn’t load from xxx)

Try this (before instantiating SoapClient):


Found this solution up here:

Input is not proper UTF-8, indicate encoding (DOMDocument::loadXML)

Probably your XML string isn’t in UTF-8. Try this:


Install composer

Composer is a dependency management for PHP and writen in PHP

curl -s | sudo php -- --install-dir=/usr/local/bin/
alias composer='/usr/local/bin/composer.phar'

Add PHPUnit to your Include Path (eclipse based IDE)

1 – Choose “Project” -> “Properties” or “Window” -> “Preferences” -> “PHP” (for global usage)
2 – Choose “PHP Include Path”
3 – Click on “Add External Source Folder” (typically PHPUnit is based on /usr/share/php/PHPUnit for linux distro)

Output while running (PHP)

for($i=0; $i<3; $i++)
   echo 'printing...';
   echo str_repeat(' ', 65536); // set a minimum output

Get only number from a string

preg_replace('/[^\d]/', '', $str);

Sum Businnes Day with PHP

function sum_business_day($date, $days) {
	list($year, $month, $day) = explode('-', $date);
	$business_day = 0;
	$add_day = 0;
	while ($add_day < $days) {
		$wday = gmdate('w', strtotime('+' . $business_day . ' day', mktime(0, 0, 0, $month, $day, $year)));
		if ($wday != 0 && $wday != 6) {
	return gmdate('Y-m-d', strtotime('+ ' . $business_day . ' day', strtotime($date)));
Page 1 of 3123