Setting Advanced
PHP Development Environment
What is development environment?
 A set of all tools that we need to develop a solution (Web

application)
 Mainly we ne...
LAMP
 Stands for Linux-Apache-MySQL-PHP

(At least in theories)
 Linux – Operating System
 Apache – Web server
 MySQL ...
Operating System
 Linux – LAMP

 Windows –WAMP
 Mac OS – MAMP
 Or any other Operating system.

4
Web Server Software
 Apache

 Nginx

(Pronounced Engine X)

 Lighttpd

 IIS
5
Database
 MySQL

 PostgreSQL
 Oracle
 MS SQL Server

 Maria DB
 IBM DB 2
 MongoDB
 Cassandra
 Neo4J
6
Programming Language

7
Setting Basic Dev Env
 OS: you must be having.

 Lets assume Windows or Linux.
 Lets set basic PHP development environm...
Basic Dev-Env on Windows
 WAMP Server



XAMPP

 Standalone Apache, MySQL, PHP

9
Basic Dev-Env on Windows
 Why WAMP/XAMPP?
 Easy one click setup.
 Easy to manage Apache/PHP

modules
 Can switch PHP/M...
Basic Dev-Env on Windows
 WAMP or XAMPP?
 Personal preference.
 WAMP is windows only,

while XAMPP is cross
platform.
...
Installing WAMP
 Download installer from http://www.wampserver.com/en/
 Install as any windows program

(Double click in...
Starting WAMP

13
Working with

14
Basic Dev-Env on Linux

Which Linux?

15
Basic Dev-Env on Linux

16
Basic Dev-Env on Linux

17
Apache
apt-get update
apt-get install apache2

yast2 -i apache2

To start with System
Systemctl enable apache2.service
sys...
MySQL
apt-get install mysql-server mysql-client

yast2 -i mysql mysql-client
mysql-community-server
To start with system
s...
MySQL
mysql_install_db

mysql_install_db

20
PHP
apt-get install php5 libapache2-mod-php5

yast2 -i apache2-mod_php5

21
Restarting Apache
sudo service apache2 restart

sudo systemctl restart apache2.service

22
PHP Modules
apt-get install php5-mysql php5-curl php5-gd php5intl php-pear php5-imagick php5-imap php5-mcrypt
php5-memcach...
So LAMP/WAMP is now up and
running
You can develop and work on nearly any web application.

But
Is it sufficient?
24
Example
 Suppose you are making a site






25

http://www.abccorp.com
Where will you put files?
X:wampwwwabccorp
Ho...
Virtual host on WAMP
 Step 1: update hosts file

 Open notepad as administrator.
 Open file

C:Windowssystem32drivers
e...
Virtual host on WAMP
 Step 2: Update httpd.conf

 Search and uncomment

# Include conf/extra/
httpd-vhosts.conf

27
Virtual host on WAMP
 Open file
X:WAMPWWWapacheapacheXXXconfextrahttpd-vhosts.conf

 Add following:
<VirtualHost *:80>
S...
Virtual host on Ubuntu
 Open /etc/hosts file in editor and add





29

127.0.0.1 local.abccorp.com
Copy /etc/apache2...
Virtual host on Ubuntu
 Also update document root

DocumentRoot /path/to/project/web/root
 Enable site
a2ensite local.ab...
JDK or JRE
 Yes, even as PHP developer, we need Java Development Kit

of at least Java Runtime environment because:
IDE
...
PEAR
 PHP Extension and Application Repository.

 Lot of good PHP extensions/library.
 Install system based dependencie...
Composer
 Composer is PHP Dependency Manager, which install

project specific dependencies.
 Most modern framework now u...
Installing Composer

 Linux

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

...
PHP Unit
 PHP Unit is Unit testing framework/tool.

 Do you need Unit Testing?
 NO because:
I’m genius and never make ...
Installing PHP Unit
 With Composer
{
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}

 With PHAR
wget https://phar.phpun...
Code Quality
 Any fool can write a code that computer can understand.

Good developers write code that humans can underst...
Code Sniffer
 Installation

pear install PHP_CodeSniffer
 Usage

phpcs --standard=ZEND /path/to/code/file.php
 More Inf...
Virtual Machine
 Virtual Machine allow to run one virtual Operating System

from with in other, without dual booting.
 M...
Vagrant, Puppet/Chef
 Vagrant is ‘Virtual Development Environment’.

 Puppet and Chef are ‘Configuration Management Soft...
Vagrant Setup
 Install Oracle Virtual Box

Go to www.virtualbox.org, download installer and install
Virtual Box.
 Instal...
Vagrant up
 Create new box

vagrant init precise32 http://files.vagrantup.com/precise32.box

 Start vagrant

vagrant up
...
About Me & Question
 Name: Kapil Sharma (I’m not comedian)

 Twitter: @kapilsharmainfo

Any Question?

43
Upcoming SlideShare
Loading in...5
×

Setting advanced PHP development environment

1,307

Published on

Slides of presentation during Pune PHP MeetUp.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,307
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Setting advanced PHP development environment"

  1. 1. Setting Advanced PHP Development Environment
  2. 2. What is development environment?  A set of all tools that we need to develop a solution (Web application)  Mainly we need Operating System Server Software Database Programming Language 2
  3. 3. LAMP  Stands for Linux-Apache-MySQL-PHP (At least in theories)  Linux – Operating System  Apache – Web server  MySQL – Database  PHP – Programming Language  This is just a general definition.  In modern app, all 4 can be changed.  So what are possible options? 3
  4. 4. Operating System  Linux – LAMP  Windows –WAMP  Mac OS – MAMP  Or any other Operating system. 4
  5. 5. Web Server Software  Apache  Nginx (Pronounced Engine X)  Lighttpd  IIS 5
  6. 6. Database  MySQL  PostgreSQL  Oracle  MS SQL Server  Maria DB  IBM DB 2  MongoDB  Cassandra  Neo4J 6
  7. 7. Programming Language 7
  8. 8. Setting Basic Dev Env  OS: you must be having.  Lets assume Windows or Linux.  Lets set basic PHP development environment on 8
  9. 9. Basic Dev-Env on Windows  WAMP Server  XAMPP  Standalone Apache, MySQL, PHP 9
  10. 10. Basic Dev-Env on Windows  Why WAMP/XAMPP?  Easy one click setup.  Easy to manage Apache/PHP modules  Can switch PHP/MySQL versions (limited to available on WAMP) 10  Why Standalone?  More control over different versions.  Can replicate production server better.
  11. 11. Basic Dev-Env on Windows  WAMP or XAMPP?  Personal preference.  WAMP is windows only, while XAMPP is cross platform.  My personal preference (if that matter) is WAMP.  Here I’m concentrating on WAMP. 11
  12. 12. Installing WAMP  Download installer from http://www.wampserver.com/en/  Install as any windows program (Double click installer 12 )
  13. 13. Starting WAMP 13
  14. 14. Working with 14
  15. 15. Basic Dev-Env on Linux Which Linux? 15
  16. 16. Basic Dev-Env on Linux 16
  17. 17. Basic Dev-Env on Linux 17
  18. 18. Apache apt-get update apt-get install apache2 yast2 -i apache2 To start with System Systemctl enable apache2.service systemctl start apache2.service 18
  19. 19. MySQL apt-get install mysql-server mysql-client yast2 -i mysql mysql-client mysql-community-server To start with system systemctl enable mysql.service systemctl start mysql.service 19
  20. 20. MySQL mysql_install_db mysql_install_db 20
  21. 21. PHP apt-get install php5 libapache2-mod-php5 yast2 -i apache2-mod_php5 21
  22. 22. Restarting Apache sudo service apache2 restart sudo systemctl restart apache2.service 22
  23. 23. PHP Modules apt-get install php5-mysql php5-curl php5-gd php5intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-cli yast2 -i php5-mysql php5-curl php5-gd php5-intl phppear php5-imagick php5-imap php5-mcrypt php5memcache php5-ming php5-ps php5-pspell php5recode php5-snmp php5-sqlite php5-tidy php5xmlrpc php5-xsl php5-cli 23
  24. 24. So LAMP/WAMP is now up and running You can develop and work on nearly any web application. But Is it sufficient? 24
  25. 25. Example  Suppose you are making a site     25 http://www.abccorp.com Where will you put files? X:wampwwwabccorp How will you access site? http://localhost/abccorp If you are using framework, say symfony http://localhost/abccorp/web Would you like to use http://local.abccorp.com
  26. 26. Virtual host on WAMP  Step 1: update hosts file  Open notepad as administrator.  Open file C:Windowssystem32drivers etchosts  Add following line at bottom 127.0.0.1 local.abccorp.com 26
  27. 27. Virtual host on WAMP  Step 2: Update httpd.conf  Search and uncomment # Include conf/extra/ httpd-vhosts.conf 27
  28. 28. Virtual host on WAMP  Open file X:WAMPWWWapacheapacheXXXconfextrahttpd-vhosts.conf  Add following: <VirtualHost *:80> ServerAdmin emailaddress@domain.com DocumentRoot "c:projectsabccorp" ServerName local.abccorp.com ErrorLog "logs/abccorp.log" CustomLog "logs/abccorp-access.log" common </VirtualHost>  Restart apache and access http://local.abccorp.com 28
  29. 29. Virtual host on Ubuntu  Open /etc/hosts file in editor and add     29 127.0.0.1 local.abccorp.com Copy /etc/apache2/sites-available/default to /etc/apache2/sites-available/local.abccorp.com Edit newly created file and change ServerName local.abccorp.com <VirtualHost *:80> ServerAdmin webmaster@abccorp.com ServerName local.abccorp.com ServerAlias local.abccorp.com
  30. 30. Virtual host on Ubuntu  Also update document root DocumentRoot /path/to/project/web/root  Enable site a2ensite local.abccorp.com  Reload and restart apache service apache2 reload service apache2 restart  Access site local.abccorp.com 30
  31. 31. JDK or JRE  Yes, even as PHP developer, we need Java Development Kit of at least Java Runtime environment because: IDE Many Java based tools, important during SDLC. • Nearly all OS come with some JRE (Not Sun/Oracle JRE) • For best result, prefer Oracle JDK or JRE. • Download installer from http://www.oracle.com/technetwork/java/javase/downloads/index.html • And follow instruction to install. 31
  32. 32. PEAR  PHP Extension and Application Repository.  Lot of good PHP extensions/library.  Install system based dependencies by default.  Personally: Composer recommended. 32
  33. 33. Composer  Composer is PHP Dependency Manager, which install project specific dependencies.  Most modern framework now use composer for downloading dependencies.  PHP-FIG effect. 33
  34. 34. Installing Composer  Linux curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer  Windows Download installer from getcomposer.org 34
  35. 35. PHP Unit  PHP Unit is Unit testing framework/tool.  Do you need Unit Testing?  NO because: I’m genius and never make mistake. No budget (My client can afford bugs but budget cant be increased) I don’t want to learn something new (I do not care … ) • Yes, but I don’t know how to test? No issue, install it and learn it. 35
  36. 36. Installing PHP Unit  With Composer { "require-dev": { "phpunit/phpunit": "3.7.*" } }  With PHAR wget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar mv phpunit.phar /usr/local/bin/phpunit phpunit –version php phpunit.phar --version 36
  37. 37. Code Quality  Any fool can write a code that computer can understand. Good developers write code that humans can understand. – Martin Fowler.  Refactoring/Design Patterns/Unit Testing/OOPs.  At least start following coding conventions. Use code sniffer to force you doing that. 37
  38. 38. Code Sniffer  Installation pear install PHP_CodeSniffer  Usage phpcs --standard=ZEND /path/to/code/file.php  More Info http://pear.php.net/manual/en/package.php.phpcodesniffer.intro.php 38
  39. 39. Virtual Machine  Virtual Machine allow to run one virtual Operating System from with in other, without dual booting.  Most popular Virtual Machines are:  Oracle Virtual Box.  VM Ware 39
  40. 40. Vagrant, Puppet/Chef  Vagrant is ‘Virtual Development Environment’.  Puppet and Chef are ‘Configuration Management Software’.  With proper use of Vagrant and Puppet/Chef, we can make development environment, very similar to production environment.  Ensure all developers have same development environment. 40
  41. 41. Vagrant Setup  Install Oracle Virtual Box Go to www.virtualbox.org, download installer and install Virtual Box.  Install Vagrant Go to www.vagrantup.com/downloads and download suitable installer. Install as per platform 41
  42. 42. Vagrant up  Create new box vagrant init precise32 http://files.vagrantup.com/precise32.box  Start vagrant vagrant up This command will start server.  Login to virtual machine vagrant ssh  Stop vagrant vagrant halt  Further steps Configure vagrant box with Puppet/Chef 42
  43. 43. About Me & Question  Name: Kapil Sharma (I’m not comedian)  Twitter: @kapilsharmainfo Any Question? 43
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×