Saturday, 26 December 2015

What is Composer in php? - Manage the Dependencies

What is Composer in php? -  Manage the Dependencies


Question: What is Composer?
Composer is an application-level package manager for the PHP.


Question: Why Composer is used?
  1. Composer provides a standard format for managing dependencies of PHP software.
  2. Composer installs the dependencies libraries.
  3. Composer provides autoload capabilities for libraries.


Question: Where composer is used?
When we need manage the dependencies of PHP application, we can use Composer.


Question: How Composer Works?
It works commond line.


Question: Who developed the Composer?
  1. Nils Adermann.
  2. Jordi Boggiano.
.

Question: What is current stable version of Composer?
1.2.0 / July 18, 2016.


Question: In Which language, It was writeen?
PHP.


Question: What is offical website of Composer?
http://getcomposer.org/


Question: What are System Requirements for compser?
  1. PHP 5.3.2+
  2. Need git, svn or hg repository depend of composer version.


Question: What is command to download the composer?
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');"
You need curl OR openssl enable for above command.


Question: How to install the composer?
php composer.phar install



Question: How to update the composer?
php composer.phar update



Question: How to check current version of composer?
php composer.phar -V



Question: Can I used composer standard for my new project?
Yes, you can start.


Question: Is it open-source?
Yes, It is open-source.


Question: Give me sample of composer.json file?
{
    "name": "zendframework/skeleton-application",
    "description": "Skeleton Application for ZF2",
    "license": "BSD-3-Clause",
    "keywords": [
        "framework",
        "zf2"
    ],
    "homepage": "http://framework.zend.com/",
    "require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "2.3.2"
    }
}

Thursday, 24 December 2015

How to install Zend Framework 2 in windows


How to install Zend Framework 2 in windows

  1. Add PHP.exe Path to Your Windows Path Variable.
    Means we need to add php.exe's path to windows path variable So that you can execute php commands.
    (My php.exe Path: E:\wamp\bin\php\php5.4.3)
    Not understand OR any Doubt 
  2. Make sure you have >=PHP5.4 Version.
  3. Now download Zend Framework 2.3.2 From https://github.com/zendframework/ZendSkeletonApplication/releases/tag/release-2.3.2
  4. Unzip this zipped file .
  5. Rename ZendSkeletonApplication to zf2.
  6. Copy this zf2 folder to E:\wamp\www
  7. Login to command prompt & Go to www folder of wamp (Path: E:\wamp\www\zf2)
  8. Now download composer with following command.
    php -r "readfile('https://getcomposer.org/installer');" | php
    If the above fails, enable php_openssl.dll in php.ini & Restart wamp Server.
  9. Now execute following command to install the composer
    php composer.phar install
  10. Apache Setup  (Path: E:\wamp\bin\apache\apache2.2.22\conf\extra)
    <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>
  11. Append following line in host File (Path:C:\Windows\System32\drivers\etc)
    127.0.0.1       zf2.loc
  12. ReStart your wamp Server.
  13. http://zf2.loc in Web Browser