PHPUnit – configure unit testing using phpunit.xml

Include bootstrap file before running actual test case. This is very helpfull when we are working with other packages & frameworks. phpunit command checks for the existence of phpunit.xml file in the directory where the command has been executed. If it find updates configuration respectively & loads bootstrap file & then executes unit tests. Sample

PHPUnit – Start writing simple test cases

How to write your first test case Every test case is started with test*. We are writing our first test case in FirstTest.php. FirstTest.php class extends PHPUnit_Framework_TestCase.php class of PHPUnit Framework.   Command to execute test case Run FirstTest.php test cases using project spacific installation done using composer. See First Chapter  Output on running test

PHPUnit – Installation

Installation on Linux system PHPUnit 4.0 is the current stable release series of PHPUnit. It became stable on March 7, 2014. Install using the PEAR Installer. Commands to install   It can be installed using .phar file. Download .phar file Make it executable Move it to user bin path. Check the installed version.   Install using composer  Learn how composer

PHP5.5 || Finally Keyword

PHP5.5 introduced a new keyword finally. Now it provides more concern about resource handling. It is much like Java. Finally keyword is used with try/catch/finally pair. Code block in finally will always be executed no matter an exception occurs or not.

PHP || How to check a json is valid

Almost all web developer may have idea of JSON. JSON is a lightweight string format which is language independent, So it is used in data transfer between web application. PHP has two inbuilt json_encode() & json_decode() function which are used to encode & decode JSON. Normally we encode a set of data which is an

How to check whether a string is Boolean or not in PHP

Boolean is data type which can have only two values (TRUE/FALSE). The function is_bool() checks a string is it Boolean or not. PHP provides a function filter_var() which has great utility to check variables. It can also validate boolean strings’s.  

How to make asynchronous REST call using cURL in PHP

Generally we make synchronous request using REST call in PHP. We want to wait for response of our REST call.But some time we need to send a request only, do not want to wait for the response. In such case we want to make an asynchronous request. cURL has no other way to support asynchronous

Setup phpMyAdmin with apache on Ubuntu

phpMyAdmin is a free software to manage MySQL Databases. Install phpMyAdmin It’s the easiest way to install phpMyAdmin with apt-get.  Setup with Apache Step-1. Edit apache configuration Step-2. Add the phpmyadmin config to the apache configuration. Step-3. Restart apache  After restarting apache webserver you can access phpMyAdmin by http://localhost/phpmyadmin.

Add environment variable with apache

The Apache HTTP Server provides a mechanism for storing information in named variables that are called environment variables. This information can be used to control various operations such as logging or access control. Environment variable can be added by putting following line to apache2.conf.   This Environment variable is accessible in CGI Scripts or Server side scripts.

Yii2 basic application demo

Download the code from github for basic application build using Yii2 Framwork.