Skip to main content

Posts

Showing posts from October, 2014

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

Symfony Tutorials: Event Dispatcher

Symfony EventDispatcher is object which interacts with different set of objects when certain event happens. To illustrate Event Dispatcher definition let’s consider the online shopping website example. suppose  you want to purchase a mobile f rom online shopping website , but unfortunately that mobile is out of stock. Then you subscribe into online shopping website for this mobile availability. When mobile comes in stock, online shopping website notifies you about mobile phone’s availability via email. In above scenario you are the Event Listener / Event Subscriber mobile availability is Event online shopping website is Event Dispatcher . Symfony EventDispatcher works in same manner.for example, whenever there is HTTP request, Kernel creates a request object and it dispatches an event kernel.request . Whoever subscribes to kernel.request event gets notified. So here you might be having few questions in my mind. What is Event?

Subscribe for latest tutorial updates

* indicates required