Skip to main content

Posts

Showing posts from 2014

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

With some examples, this tutorial post will teach the PHP autoloader and namespace concepts. What is Autoloading in PHP? PHP autoload's primary function is to load PHP files into the application context. The import statement is the default method to include PHP file into context. However, we may avoid the issue by using the PHP autoload capability to autoload essential PHP files, which keeps your code clean and composable. Why do we need auto loading? When creating object-oriented applications, many developers create one PHP source file per class declaration. One of the major inconveniences is having to start each script with a huge list of required includes. Autloading allows us to include an arbitrary number of PHP files in the application context if they aren't already included by other include statements.  PHP Autoloading Methods PHP uses two functions; one is the magic method spl_autoload_register  and the other is   __autoload . Although __autoload has been

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 Tutorial: Installation and Configuration

In this tutorial, we will look at how to install Doctrine2 in your PHP project. This post will make use of Doctrine2's Composer tool. Installation First, create a directory for your project. mkdir zainabed cd zainabed Now, create a composer.json file. vi composer.json Then, add the following repository information to it . { "require" : { "doctrine/orm" : "*" } } You are now ready to use Composer to install Doctrine, but first you must install Composer on your machine. curl -sS https://getcomposer.org/installer | php To install Doctrine2, run the following command. php composer.phar install Note: Composer generates a "autoload.php" file to help in the autoloading of all PHP classes in the Doctrine2 ORM project. Configuration First, create a configuration file, configuration.php  for Doctrine2 and include  autoload.php  inside it. <?php // configuration.php // In

Twig Tutorials: Install and Configure

In this tutorial, we'll look at how to install Twig within your PHP project and thereafter configure it so that we can create and use a Twig template inside our PHP web application. Later on, we'll see a simple Twig template example that displays a "Welcome to Twig template" message. Let's take it one step at a time. Install The Twig template can be installed using Composer, Git, or PEAR. In this tutorial, we will use Composer to install Twig. To do so, we'll need to make a "composer.json" file. { "require" : { "twig/twig" : "1.*" } } From the console, run the following command . $ php composer.phar install This command will install Twig library. Configuration To use the Twig template, we should first configure it. To achieve this, we will write an index.php file which will configure the Twig autoloader and generate the Twig environment. We will render the Twig temp

How to create an SSH key for GitHub and Bitbucket

This post will show you how to generate SSH private and public keys step by step, as well as how to add public keys to your GitHub and Bitbucket accounts. But first, why do we require this SSH public key? If you want to do any work on a secure GIT repository, such as cloning or pushing your latest changes, you will need to provide your credentials to help GIT authenticate you and approve those operations, whether you are working in a team or as an individual. However, each time you operate, you are prompted to enter your username and password. It appears simple at first, but it quickly becomes a source of frustration. To overcome the above problem, we can use the SSH protocol. SSH connections allow us to authenticate using public and private keys that we generate only once. after that, we don't need to authenticate because SSH will do so on our behalf. But how does it work? SSH authenticates you using an identity, and this identity is made up of a combination of private an

Subscribe for latest tutorial updates

* indicates required