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. 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. Operating System
Linux – LAMP
Windows –WAMP
Mac OS – MAMP
Or any other Operating system.
4
8. Setting Basic Dev Env
OS: you must be having.
Lets assume Windows or Linux.
Lets set basic PHP development environment on
8
9. Basic Dev-Env on Windows
WAMP Server
XAMPP
Standalone Apache, MySQL, PHP
9
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. 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. Installing WAMP
Download installer from http://www.wampserver.com/en/
Install as any windows program
(Double click installer
12
)
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. 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
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. 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. 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. Virtual host on WAMP
Step 2: Update httpd.conf
Search and uncomment
# Include conf/extra/
httpd-vhosts.conf
27
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. 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. 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. 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. PEAR
PHP Extension and Application Repository.
Lot of good PHP extensions/library.
Install system based dependencies by default.
Personally: Composer recommended.
32
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. 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. 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
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. 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. 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. 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. 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. 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. About Me & Question
Name: Kapil Sharma (I’m not comedian)
Twitter: @kapilsharmainfo
Any Question?
43