The PHP Workshop, a real online course designed around a real book

Interested to learn PHP Web Development?

Here you go, the seven experienced developers co-authored to bring in a fresh new PHP book and a workshop with Packt Publishing for whom who wanted to start a PHP web development career.

Why the workshop is important?

So many excellent new books are coming to your hand but there are missing blocks in between the learning process. Developers start reading a book and practicing examples, and if serious enough in learning, maybe completing one or two small projects with the help of those books. Surely, there are some places in the learning route where developers get puzzled and seek for guidance, explanation, and support. This is where the workshop comes in which is intended to train you through guided steps along with the book in your hand. Hence, you have the book (read route map) and the workshop (read a trustworthy friend) to demonstrate, guide and suggest the foundations/basics, ideas behind, perspective and techniques. Therefore, in the end, you feel confident enough to tackle real-world development.

Where to avail?

Check out the book at Amazon, “The PHP Workshop: A Practical, No-Nonsense Introduction to PHP Development” https://amzn.to/2NRz3i6

For UK readers, https://amzn.to/32SPPBN

Also, in iTunes library https://apple.co/2pp9jAg

The online workshop worth $29.99 is available at Packt courses https://courses.packtpub.com/courses/php

What the Book gives you?

This book covers most of the aspects of PHP web development, the book should be laying the essentials with PHP Basics like familiarization with the environment, variables, data types, operators, control statements and functions. Then give you writing reusable codes with Object-Oriented Programming concepts in very fine detail with the real-world examples. Talking over HTTP, Data Persistency and Error Handling should be giving you another layer of knowledge. Then you can start Composing your own PHP project and start mashing up Web Services. You should check out the Table of Contents to understand the full depth of the contents.

A Certificate is Sweet!

Finally, on successful completion, you do get a Certificate.

Packt Courses seal a record of your certification on the public Bitcoin blockchain. This verifies your achievement and lets employers authenticate your status with Packt.

PacktPub Courses

Please leave comments for further queries and suggestions.

Register Doctrine2 type mapping with Symfony2

Well, few of us may have encountered such error while using Doctrine like “Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.” or in my case I was trying to use “enum” type with doctrine.

So, here is the app/config.yml hack at mapping_types:

# Doctrine Configuration
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8

          enum: string
          set: string
          varbinary: string
          tinyblob: text
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

Setting your PHP development environment in Ubuntu

Instead of installing each item separately we will go with installing LAMP server in a package in Ubuntu that is fairly simple along with a single terminal command:

sudo apt-get install lamp-server^

The apt-get command is a powerful command-line tool used to work with Ubuntu’s Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.

sudo used to invoke the current user with the power of super user and a caret ‘^’ symbol placed after package name to indicate performing as tasks together.

The LAMP package will start installing immediately with above command including latest PHP5, Apache 2, MySQL and PHP5-MySQL. By default apache2 and MySQL installed as service and your document root will be at /var/www/

An index.html file shall be there.

Both Apache and MySQL should be running. However, you may start apache by using service start command as

sudo service apache2 start

and stop apache by using:

sudo service apache2 stop

Checking the LAMP installation:

Point your browser to http://localhost/ you will see the default apache2 landing page which means your webserver apache2 is running. Still you can check those service statuses as below:

sudo service apache2 status

you will be shown

Apache is running. Process #

Again to check MySQL status, simple run the command

sudo service mysql status

you will be shown

mysql start/running. Process #

to check the PHP installation simple create a file named test.php, in /var/www/ with the below line:

<?php phpinfo(); ?>

Now point your browser with http://localhost/test.php and you will see the installed PHP and components configuration details.

Installing PhpMyAdmin:

To maintain MySQL database functionality using web based interface we may use phpMyAdmin.

sudo apt-get install phpmyadmin

phpMyAdmin will be installed with the above command and during installation you will receive a blue window asking which server you want to use i.e. apache2, lighttpd ;  choose apache2 and click ok to continue with the installation. After installation point your browser with http://localhost/phpmyadmin/ and you will be viewing phpMyAdmin landing page.

If you receive 404 error at http://localhost/phpmyadmin/ then you need to setup phpMyAdmin under apache manually by modifying /etc/apache2/apache2.conf using gedit

sudo gedit  /etc/apache2/apache2.conf

gedit will open the file in graphical mode and add the below line at bottom inside apache2.conf

Include /etc/phpmyadmin/apache.conf

Now restart apache server to make the changes effective.

sudo service apache2 restart

Now refresh your browser and you will have phpMyAdmin login screen.

BASIS SoftEXPO 2012 Tech session: Build Social Apps for Facebook

The below application created to describe simple Facebook social plugins usage and how to develop a Facebook app from scratch.

The demo Facebook application : BookStall

The Entire Facebook application source code can be downloaded from here:

Virtual bookstall project source codes

screen-casts will be added soon 🙂 [N.B: 44 minutes screen-casts are too heavy to upload, skipped this]

This above session has been presented at BASIS SoftEXPO 2012

PhpXperts Seminar 2011 – follow up

17th December 2011, on tech premises at the heart of Dhaka, the largest tech seminar took place once again featuring latest web trends and interesting PHP sessions brought by the experts from the industry. In this 5th annual program of phpXperts, more than 500 developers, open source enthusiasts, journalists, students, geeks joined the daylong event to inhabit the tech gathering which finally became huge success and significant in the local PHP community.

This long awaited annual program included with a new addition of short sessions of 6 minutes each along with regular sessions with speakers and the sponsors presented their companies or projects within the event frame. The pretty item in the seminar was the quiz session after each two speaking and winners were awarded with many exciting gadgets.

Basically openness & friendliness of phpXperts community became the icon of tech community of the country, more auspicious developers have been stimulated from the phpXperts. This enormous tech group feeds heavy input to local web industry and the web generation of Bangladesh.

Hasin Hayder, the man behind the scene, doing the hard work as founder-moderator of the group and the mentor to local PHP community.

Seminar references are as below:


Sessions with Speakers

Lets have some fun with – Twilio & OpenTok APIMizanur Rahman

Get Excited! Enterprise Search Solutions at your FingerTipsMurshed Ahmmad Khan

Dependency Injection, Reinventing how you manage PHP classesRifat Nabi

Setting up Amazon EC2 Servers: Make Your Server Elastic!Tahsin Hasan

Continuous feature integration in large projectsNHM Tanveer Hasan Khan & Nafi ul karim

MongoDB, a document store that won’t let you down!Nurul Ferdous

Getting Up and running with Zend FrameworkMd. Shoriful Islam Ronju & Saidur Rahman Bijon

A Brief Intro to the Symfony Application Framework v2.xLoban Amaan Rahman

Screencast: http://www.youtube.com/watch?v=ENR3qXdNOXY

Taking Advantage of Client Side / JavaScript Templates in Rich Internet Applications. – M. Mahbubur Rahman

Hybrid authentication and talking to social networksRayhan Chowdhury

Supervisor, Gearman and PHP – Job management with sanity!Abu Ashraf Masnun

Mystery of cryptography, ciphers and the dark side of the moonHasin Hayder & M A Hossain Tonu


6 minutes of Fame

Smelling Your CodeRaju Mazumder

WordPress plugin / theme development best practicesTareq Hasan

Flying on the cloudImran Hossain Shaon

Rapid facebook application development using LightBulb – Md. Alamgir Hossain Rinku

ZCE – Inside OutShehzad Noor Taus

RESTful Web ServicesMd. Eftakhairul Islam Rain

Download all the presentation slides:


Seminar booklet:

Cover Design of the booklet of phpXperts

Photo Albums:



Seminar follow up in Bengali:


Cheers 🙂

Multiple Database from application.ini in Zend Framework

place something like in your application.ini


resources.multidb.db1.adapter = "pdo_mysql"
resources.multidb.db1.host = "localhost"
resources.multidb.db1.username = "webuser"
resources.multidb.db1.password = "XXXX"
resources.multidb.db1.dbname = "db1"

resources.multidb.db2.adapter = "pdo_pgsql"
resources.multidb.db2.host = "example.com"
resources.multidb.db2.username = "dba"
resources.multidb.db2.password = "notthatpublic"
resources.multidb.db2.dbname = "db2"
resources.multidb.db2.default = true

you should declare the default database as we did in
resources.multidb.db2.default = true

if you want to retrieve a specific database adapter may use from followings:

$resource = $bootstrap->getPluginResource('multidb');

$db1 = $resource->getDb('db1');

$db2 = $resource->getDb('db2');

$defaultDb = $resource->getDb();
$defaultDb = $resource->getDefaultDb();

getDb() returns an instance of a class that extends Zend_Db_Adapter_Abstract.
If you have not set a default database, an exception will be thrown when this method is called without specifying a parameter.

code says it all 🙂


Bootstrap-ing in Zend Framework


Bootstrap.php inside your application directory runs before your application loads in order to process auto loading of resources. resource auto loading can be performed in two ways using either Bootstrap.php or application.ini for an application.

Bootstrap methods used as initialize-r should be of protected and begin with _init.

As an example, you want to initialize language translation resource, create a method like _initTranslation() as below:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
      protected function _initTranslation(){
      //translation enabling codes here

bootstrap methods are named according to functionality i.e. _initLayout(), _initViewHelpers(), _initRoutes() etc.

here are two examples of bootstrap methods:

jQuery, jQuery ui/css enabler

 * enable jquery, jqueryui, css
protected function _initJquery() {
  $view = $this->getResource('view');

  //add jquery view helper path
  $view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
  //jquery lib includes here

in the above code we just enabled to make available jQuery, ui to our application.

doc type, header

 * declare header, doc type etc.
protected function _initDoctype() {
   $view = $this->getResource('view');

   //doc type
   $view->headMeta()->appendHttpEquiv('Content-type', 'text/html;charset=utf-8')
        ->appendName('description', 'test description');

in the above method we declared doc type, charset etc. for our html documents belongs to the application.

Using Multiple Layouts in Zend Framework

Followed by my earlier post >>

Besides using default layout you can use multiple layouts or can switch between layouts. All you need to do is just pick the layout object and set the desired layout name.

Here is a scenario:

Say you have 2 layouts at application/layouts/scripts/ i.e. layout.phtml and layout1.phtml

As layout.phtml is your default layout and you need to use layout1 in some cases. To do that we need to pick the layout object as mentioned earlier, there are several ways.

Access a layout object:

At view scripts:

<?php $layout = $this->layout(); ?>

At action controller:

$layout = $this->_helper->layout();

Static method elsewhere:

$layout = Zend_Layout::getMvcInstance();

At bootstrap:

$layout = $bootstrap->getResource('Layout');

Set the desired layout (the layout will work within defined scope):


i.e. If you set the layout at any action controller then the layout will be viewed for that particular action.

For more reading


Enabling Layout in Zend Framework

See Category:Go images for sourcecode and usag...
Image via Wikipedia

To maintain a consistent look and feel through out your website, Zend_Layout provides layout facility by which you can create single or multiple document structures as like as templates.

Enabling Zend_Layout means informing bootstrap to use Layout resource. You can enable layout with the help of zf cli tools from terminal as:

$ zf enable layout

Layout has been enabled, and a default layout created at application/layouts/scripts/layout.phtml. A layout entry has been added to the application config file.

With the above command you will have following things ready:

–       application/configs/application.ini is updated; contains following line at your production section

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

–       A layout file created at /application/layouts/scripts/layout.phtml

Also you need to initialize the View resource; add the following line to your have application/configs/application.ini

; Add to [production] section:

resources.view[] =

Now to run view resource we will add just a little code at bootstrap:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

protected function _initView(){


$view = $this->getResource('view');

$view->doctype('XHTML1_STRICT'); //can set the doc type here



Now  Zend_Layout is ready to go; may modify the layout or add some styles. Just don’t forget to echo your content i.e. $this->layout()->content  at your layout body to display your content or view html segments:

<!-- application/layouts/scripts/layout.phtml -->

<?php echo $this->doctype() ?>

<html xmlns="http://www.w3.org/1999/xhtml">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>my title</title>



<?php echo $this->layout()->content ?>



It’s a go!

if you need to use multiple layouts, you may read my next post on multiple layout usage

Using jQuery and jQuery ui with Zend Framework

talkin' jquery ui
Image by "Cowboy" Ben Alman via Flickr


For those jQuery fanatics like me wants to jQuery enabled in their Zend framework application, zf provides view and form helpers through it ‘extras’ library, also it is handy to enable.

At Bootstrap class add the following initialization method like below:

* init jquery view helper, enable jquery, jqueryui, jquery ui css

protected function _initJquery() {

$view = $this->getResource('view'); //get the view object

//add the jquery view helper path into your project
$view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");

//jquery lib includes here (default loads from google CDN)
$view->jQuery()->enable()//enable jquery ; ->setCdnSsl(true) if need to load from ssl location
     ->setVersion('1.5')//jQuery version, automatically 1.5 = 1.5.latest
     ->setUiVersion('1.8')//jQuery UI version, automatically 1.8 = 1.8.latest
     ->addStylesheet('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css')//add the css
     ->uiEnable();//enable ui


At the <head> section of your document or at layout.html, to enable jQuery at your each pages just echo like below:


echo $this->jQuery();


So you will have jQuery and jQuery ui files added into your document section like as always:

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>


N.B: in order to use ZendX library under extras/library/ZendX, the ZendX directory path should be in your php include_path or alternatively can SymLink the ZendX directory under your /application/library/