Friday 5 January 2018

How to install Zend Framework2 in Wamp Server window7?

How to install Zend Framework2 in Wamp Server

  1. Go to home directory of wamp (For Example: c://wamp/www
  2. Download composer (If not installed)
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');";
    
  3. Download the Zend Framework2
    php composer.phar create-project zendframework/skeleton-application zf2
    
    It will take few mins to download the zend framework.
  4. Copy the composer.phar to zf2 folder
    cp composer.phar zf2
    
  5. Go to zf2 directory
    cd zf2
    
  6. Virtual Host setup
    Add following code in Apache setup
    
    <virtualhost>
        DocumentRoot "D:\wamp\www\zf2\public"
        ServerName zf2.loc
        <directory public="" wamp="" www="" zf2="">
            Options FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
        </directory>
    </virtualhost>
    
    



Wednesday 20 December 2017

Encapsulation in PHP (OOP)

Encapsulation in PHP (OOP)

Question: What is Encapsulation?
The wrapping up of "Data member" and "Member functions" into a single unit (called class) is known as encapsulation.


Question: Describe the Encapsulation?
Encapsulation means hiding the internal details of an object.
OR
Encapsulation is a technique used to protect the information in an object from the other object.


Question: Give Example of the Encapsulation?
class Arithmetic {
    private $first = 10;
    private $second = 50;

    function add() {
        return $this->first + $this->second;
    }

    function multiply() {
        return $this->first * $this->second;
    }

}

//Create the object 
$obj = new Arithmetic( );

//Add Two number
echo $obj->add(); //60
//multiply Two number
echo $obj->multiply(); //500