You are on page 1of 56

Ph.

P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 1
PHP
in the Enterprise

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 2
Michael Cheng
President / Founder,
Philosophy in Programming Society
michael.cheng@php.org.sg

(Zend Certified Engineer)

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 3
What is PHP?
• PHP is a scripting language designed for producing
dynamic web pages.

• It has evolved to include a command line interface
capability and can be used in standalone graphical
applications.

• PHP is a widely-used general-purpose scripting
language that is especially suited for web
development and can be embedded into HTML.

• It generally runs on a web server.

• Current Version: 5.2.8 - www.php.net

Source: Wikipedia - http://en.wikipedia.org/wiki/Php Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 4
History
• PHP started in 1995: Rasmus Lerdorf

• 1997: Zeev Suraski and Andi Gutmans
began a complete rewrite of PHP to
make the language more powerful.

• PHP has come of age.

• Maturity in the language's syntax &
features - perfect balance of ease of use
and performance.

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 5
Building Blocks of WWW

=

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 6
Easy to Learn & Code

=

Its Free to Use!
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 7
Its Everywhere!

=

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 8
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 9
The Thinking Man

=

Start Thinking...
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 10
Iron Thinking

Be Iron Man? Or Sit Pretty?
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 11
Let’s Start with a Smile.

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 12
One of the Greatest Minds

2
E=MC

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 13
Some of the Possibilities...

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 14
Time To Move Up...

Let’s Build Skyscrapers Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 15
Wednesday, February 18, 2009 16
Wednesday, February 18, 2009 17
Wednesday, February 18, 2009 18
Wednesday, February 18, 2009 19
Wednesday, February 18, 2009 20
Wednesday, February 18, 2009 21
Wednesday, February 18, 2009 22
Wednesday, February 18, 2009 23
Wednesday, February 18, 2009 24
Wednesday, February 18, 2009 25
Wednesday, February 18, 2009 26
Wednesday, February 18, 2009 27
Wednesday, February 18, 2009 28
Benefits
• Easy to pick-up. Syntax close to C.

• Motto: “Get Stuff Done Now”.

• Simplicity & Versatility.

• Interpreted not compiled.

• Just upload and its done!

• Support rapid & agile development.

• Ubiquity of web servers that supports PHP.

• Lower TCO.

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 29
Syntax

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 30
SOAP Client
try
{
$client = new SoapClient(’http://api.google.com/GoogleSearch.wsdl’);
$results = $client->doGoogleSearch($key, $query, 0, 10, FALSE, ’’,
FALSE, ’’, ’’, ’’);
foreach ($results->resultElements as $result)
{
echo ’<a href="’ . htmlentities($result->URL) . ’">’;
echo htmlentities($result->title, ENT_COMPAT, ’UTF-8’);
echo ’</a><br/>’;
}
}
catch (SoapFault $e)
{
echo $e->getMessage();
}

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 31
10 Point Plan:
PHP in the Enterprise
How to successful roll-out PHP in your company.

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 32
10-Point Plan
• The Team • Design Patterns
• Requirements • Testing
• Architecture • Optimization
• Tools • Deployment
• Foundation • Operations
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 33
1. The Team
• Get a team together.

• Build up knowledge on PHP.

• OOP in PHP.

• Extensions available.

• Consider PHP Certification to fast-track your
learning process.

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 34
2. Requirements
• Gather requirements.

• What does the customer want?

• What will visitors want?

• What does the customer really need?

• Functional design.

• Application flow diagrams

• Wire frames.

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 35
3. Architecture
• Don’t be so Step 3 jump
eager to - Architecture
into coding.

• Data modeling.
Technical Design
• • Modeling
Class diagrams.
• Class Diagrams
• • ER Diagramsdiagram.
Collaboration (data model)
• Collaboration Diagrams
• Use •cases.
Use Cases etc.


Tools:
High Level Architectures
• UML

• Design Patterns
Whiteboards

• SOA

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 36
4. Tools
• The right tools help you get productive fast.
Step 4 - Tools
• Development Tools:
Development:
• Eclipse• PDT
Eclipse/ PDT
PHPClipse

• •
Komodo
Zend Studio
• PhpEd
• • Vim
Zend Studio
• Komodo
• Full IDE or Text Editor?
IDE’s versus Editors
• • Debugging
Debugging / Profiling
& Profiling
• Syntax Check
• Syntax•checking
Cross-Referencing / Navigation

• Cross Referencing / Navigation
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 37
4. Tools
• Version Control

• Subversion

• CVS

• Documentation Tools

• PHP Documentor (http://phpdoc.org)

• PHPXRef (http://phpxref.sourceforge.net)

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 38
5. Foundation
• Good foundation will help in making your code
more maintainable and scalable.

• SOP & Best Practices

• Use a framework

• Zend Framework (http://framework.zend.com)

• CakePHP (http://cakephp.org)

• Symfony (http://www.symfony-project.org)

• Code Ignitor (http://codeigniter.com/)

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 39
6. Design Patterns
• Best practice way of solving a particular problem.

• Patterns:

• Model-View-Controller

• Factory

• Singleton

• Registry

• Decorator

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 40
7. Testing
• Various types of testing:

• Developer testing

• Functional testing

• Environment testing

• Performance testing

• Usability testing

• Solution: Unit Tests

• Automated testing after each change

• Prevents regressions
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 41
7. Testing
• Testing for PHP applications:

• PHPUnit http://www.phpunit.de/

• SimpleTest http://www.lastcraft.com/simple_test.php

• Continuous Integration:

• CruiseControl http://cruisecontrol.sourceforge.net/

• phpUnderControl http://www.phpundercontrol.org/

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 42
8. Optimization
• Accelerators for PHP:

• APC http://pecl.php.net/package/APC

• eAccelerator http://eaccelerator.net/

• Zend Platform http://www.zend.com/products/
zend_platform

• PHP Caching solutions:

• Zend_Cache http://framework.zend.com

• Zend Platform http://www.zend.com/products/
zend_platform

• Memcached http://danga.com/memcached/
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 43
9. Deployment
• Lifecycle:

• Develop

• Test

• Deploy to acceptance test environment

• Deploy to production server

• Use Subversion or Capistrano

• Remember the database

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 44
9. Deployment
• Basic server installation.

Linux Windows
Apache IIS
Database

PHP
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 45
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 46
10. Operations
• Monitoring Performance

• Logs

• Debugging

• A ‘root cause’ & analysis tool

• Context Capture

• Change management:

• Ticket system

• Stick to your deployment - use the DRP

• DON'T TOUCH THE LIVE ENVIRONMENT.
Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 47
10-Point Plan
• The Team • Design Patterns
• Requirements • Testing
• Architecture • Optimization
• Tools • Deployment
• Foundation • Operations

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 48
There’s More...
• Planning

• Development methodology (Waterfall / Agile)

• Software Development Life Cycle (SDLC)

• Coding best practices

• Security

• Implementation

• Good luck!

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 49
About Michael
• Web development business for 10+ years.

• Currently running a small web development &
consulting business.

• Started Singapore PHP User Group in 2006

• Regular monthly meetups since November 2007
(average turn out of 50 members); 480+ members
to date.

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 50
History
• 2nd Facebook Developer Garage at Microsoft Singapore
Auditorium (5 March 2008).

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 51
History
• BarCamp II - Maps & Mobile Unconference (21 May 2008).

Wed, 21 May 2008 NUS Extension, Park Mall

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 52
The Philosophy in
Programming Society
• Registered as Ph.P Society in July 2008.

• Endorsed By:

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 53
Upcoming Events
• PHP Meetup (26 Feb - Oracle Singapore)

• Zend-PHP Certification Course (7 March)

• Enrichment Workshops (March 2009)

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 54
Workshops
• Intro to PHP CMSs

• PHP Frameworks: A Primer

• Drupal, WordPress, Joomla Extensions Development

• Web 2.0 Mastery Foundation Course

• Building Rich Internet Apps: Javascript Frameworks

• Visit http://www.php.org.sg for more details.

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 55
Michael Cheng
michael.cheng@php.org.sg

http://www.php.com.sg
http://www.php.org.sg
http://facebook.php.org.sg

Ph.P
SOCIETY
Philosophy in Programming Society

Wednesday, February 18, 2009 56