Skip to main content


MongoDB Tutorials : Aggregation Framework

MongoDB Aggregation Framework groups set of documents together and performs certain operation on this grouped documents and returns results in the form of documents. MongoDB aggregation answer to those query which requires grouping of documents. Aggregation framework works on three type of model Aggregation pipeline Map Reduce Single Purpose Aggregation Operations Now let see how MongoDB Aggregation Framework works with simple example. Suppose you are MongoDB application developer in a respected company and you have been given a MongoDB database that holds information about human population which is distributed according to cities and their states. here is one sample document. { "city" : "ACMAR" , "loc" : [ - 86.51557 , 33.584132 ], "pop" : 6055 , "state" : "AL" , "_id" : "3500

PHP Tutorials : Autoload PHP Classes

This tutorials post will explain PHP autoloader and namespace concept using few basic question and answer regarding PHP autoload functionality along with some examples. What is Autoloading in PHP? PHP provides helper functions to include or import PHP files, if it has not been included before. if we use PHP autoload then we don't need to write require or include statement for each PHP class files. Why we need auto loading? It is a good question. why we need it, although we can write require or include statements whenever we need. As PHP has evolved using OOPs concept, we create more classes for our PHP project and create a separate PHP file for each single PHP class. Hence we increase the number of require or include statements. therefore we need some standard way to include each files rather specifying include statement by our self every time. that is why PHP has provided some useful methods to resolve this problem. PHP Autoloading Methods PHP uses two fun

JSON Tutorials : Getting Started

JSON is widely accepted text formatted structured data. JSON stands for " JavaScript Object Notation ". In general JSON can represent 1. Object of database record. 2. Object to represent a list of HTML elements. 3. Result of search query. 4. Response of an Ajax call. Here you can see JSON is used in many different areas and for many different scenarios. This means it has simple data structure. most of programming languages adopt it and it can flow easily from one connection to another. You can find JSON office definition here JSON Official Site . JSON is represented by two structural types, which includes two primitive types. Structural types Array : A sequential list of primitive data types between square brackets [ ] Object : Collection of key, value pair stored inside curly braces { }, where value would be primitive data type Primitive types : There are two primitive types key and value. " key " should be string and " value (data type)

Doctrine 2 Tutorials: Installation and Configuration

This tutorial post will help you to install Doctrine2 inside your PHP project and configure it so that you can use it's features in plain PHP project. This post illustrates installation of Doctrine2 using Composer. Installation First create your project directory mkdir zainabed cd zainabed now create composer.json vi composer.json then add following repository information. { "require" : { "doctrine/orm" : "*" } } Now you are ready to install it via composer, but first we need to install composer into you machine. curl -sS | php Then initiate following command to install Doctrine2 php composer.phar install composer creates " autoload.php " file which helps you to autoload all PHP classes of Doctrine2 ORM project. Configuration First create configuration file configuration.php  for Doctrine2 and include autoload.php inside i

Twig Tutorials: Install and Configure

In this tutorial we will see how to install Twig inside your PHP project and then configure it so that we can create use Twig template inside our PHP web application. later we see a simple Twig template example which will display "Welcome to Twig template" message. lets see each step one by one. Install we can install Twig template via Composer, Git or from PEAR. in this tutorial post we will install Twig using Composer. for that we need to create "composer.json" file. { "require": { "twig/twig": "1.*" } } the from console run following command.   php composer.phar install    this command will install Twig library. Configuration To use Twig template we need configure it first, for that we will create index.php file which will setup Twig autoloader and generate the Twig environment. using this Twig environment we will render Twig template include __DIR__ . "/vendor/twig/twig/l

How to create SSH Key for GitHub and Bitbucket

This  post  demonstrate how to  generate  SSH private and  public   key  with fundamental steps and  assist   you  to  add   public   key  inside your  GitHub  and Bitbucket account. But first why we  need  this SSH  public   key ? Whether you are working in the team or an individual and you want make any operations on secure GIT repository like clone or push your latest changes then you require to provide your credentials to help GIT to authenticate you and approve those operations. But when  you  do so,  you  are  asked  to  provide  your username &  password ,  each   time  on  each   operation . It looks  simple  earlier, but later  becomes  a  headache . SSH  connection   helps   us  to  authenticate  using public and private keys, that  we  generate only once, later  we  don’t need to  authenticate ,  SSH  will  do  this behalf of  us . But how does it  work ? SSH   authenticate  you  using  an  identity , your  identity  and this  identity   comprise   combination  of p