php 5 - the year afterconferences.oreillynet.com/.../bergmann_php_5.pdf · standard php library...

31
„PHP 5 – The Year After“ Sebastian Bergmann http://www.sebastian-bergmann.de/talks/ PHP 5 The Year After Sebastian Bergmann October, 18 th 2005

Upload: others

Post on 29-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

PHP 5 The Year After

Sebastian Bergmann

October, 18th 2005

Page 2: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Who I Am ● Sebastian Bergmann.● Born 1978.● CS Student in Bonn,

Germany.● Committer: PHP, PEAR,

Gentoo Linux, ...● Author of Open Source

PHP projects like PHPUnit or phpOpenTracker.

● Author for online and print media.

Page 3: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Who Are You? ● Who of you uses PHP 5?● Who of you have heard

of– PHPUnit2?– Phing?– Propel?– Agavi?

Page 4: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Happy Birthday, PHP! ● PHP is 10 years, 4 months, and 10 days old.

From: [email protected] (Rasmus Lerdorf)Subject: Announce: Personal Home Page Tools (PHP Tools)Date: 1995/06/08Message-ID: <[email protected]>#1/1X-Deja-AN: 104053006organization: nonenewsgroups: comp.infosystems.www.authoring.cgi

Announcing the Personal Home Page Tools (PHP Tools) version 1.0.

These tools are a set of small tight cgi binaries written in C.They perform a number of functions including:

.

.

.

The tools are in the public domain distributed under the GNUPublic License. Yes, that means they are free!

Page 5: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

A Look Back ● PHP 3

– Released on June 6, 1998.– Very rudimentary support for object-oriented

programming.– No session management.

● PHPLIB

– Possibly the most important library for PHP 3.– Developed by Kristian Köhntopp, Ulf Wendel et

al. at NetUSE AG in Kiel, Germany.– Sascha Schumann's code for serialization of PHP

variables and session management, which was part of PHPLIB, was the de-facto standard for PHP 3.

Page 6: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

A Look Back ● PHP 4

– Released on May 22, 2000.– Rudimentary support for object-oriented

programming.– Sascha Schumann rewrote his serialization and

session management code (which was part of PHPLIB) in C and it became (as ext/session) part of PHP.

● PEAR– Repository of reusable classes and components

written in PHP.– Infrastructure (PEAR Installer) to install and

maintain packages.

Page 7: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Today ● PHP 5

– Released on July 13, 2004.– Good support for object-oriented programming.

● Language Features.● Standard PHP Library (SPL).● Extensions like DOM and MySQLi offer APIs for OOP.

– Good support for working with XML technologies and Web Services.

● PECL– PHP Extension Community Library.– Extensions to PHP written in C.– Not commonly used extensions (for example dio, fam,

yp, ...) are unbundled from the standard PHP distribution and moved to PECL.

– Commonly used PECL extensions (for example SQLite) are bundled with the PHP standard distribution.

Page 8: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Today ● PHP 5.1

– Released on Month, Day 2005.– Optimized Virtual Machine (VM).

● Up to 40% better performance compared to PHP 5.0 and PHP 4.4.

– PHP Data Objects (PDO)● Built-In Database Abstraction Layer on the API level.

– Unified new PDO(...) instead of mysql_connect(...), pg_connect(....), ...

– XMLReader API for XML processing.– Improved

● Date and Time Processing.● Standard PHP Library (SPL).● Support for IBM DB2 (developed by IBM).● Support for Oracle (developed by Oracle, Zend and

OmniTI).

Page 9: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Today ● PEAR 1.4

– Released on September 18, 2005.– Most important update to the PEAR/PECL

infrastructure to date.● Channels.● Mirroring.● Binary PECL packages.● New package.xml 2.0 format.● Self-Installing PEAR from a single file (thanks to

PHP_Archive).

Page 10: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

A Look Ahead ● PHP 6

– To be released in (early) 2006.– Full support for Unicode.

● Based upon IBM's International Components for Unicode (ICU).

– Input Filtering.– Default Bytecode Cache / Optimizer?– Namespaces?– Removal of

● register_globals?● magic_quotes_*?● safe_mode?● „stuff“ that has been deprecated since PHP 3 / 4?

Page 11: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Projects that use PHP 5 ● PHPUnit2

– Framework for Unit Tests, PHP port of JUnit.● Phing

– Project build system that follows the design of Apache Ant.

● Propel– Full-Service object persistence and query toolkit

that follows the design of Apache Torque.● Agavi

– Framework for building PHP applications based on the Model-View-Controller design pattern.

Page 12: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

PHPUnit2 ● Framework for Unit Testing.● Features include

– Complete port of JUnit 3.8.1 for PHP 5.– Support for Agile Documentation (TestDox).– Support for Code Coverage analysis with Xdebug.– Support for Incomplete Tests.– Support for Mock Objects (under development).– Integration with Phing.– Skeleton Generator for test classes.– Logging to PEAR::Log sinks and in XML format.

Page 13: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

PHPUnit2

Page 14: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

PHPUnit2

● Conventions– Tests for class Class in class ClassTest.– Tests written as methods with prefix test.

Page 15: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

PHPUnit2

Page 16: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

PHPUnit2

Page 17: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

PHPUnit2

Page 18: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Phing ● Project build system following the design of

Apache Ant.● Features include

– file transformations,● e.g. token replacement, XSLT transformation, Smarty

template transformations– file system operations,– SQL execution,– CVS and Subversion operations,– tools for creating PEAR packages,– running PHPUnit2 tests and generating test

reports.● Installation

– pear install http://phing.info/pear/phing-current.tgz

Page 19: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Phing <?xml version="1.0"?>

<project name="FooBar" default="dist" basedir=".">

<target name="prepare"> <echo msg="Preparing build..." /> <mkdir dir="./build" /> </target>

<target name="build" depends="prepare"> <echo>Building...</echo> <copy file="./src/File.php" to="./build/File.php"/> <copy file="./src/File2.php" to="./build/File2.php"/> </target> <target name="dist" depends="build"> <echo message="Creating archive..." /> <tar outfile="furbee.tar.gz" basedir="./build"/> </target> <target name="clean"> <echo msg="Cleaning up..."/> <delete file="./build"/> </target></project>

Page 20: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Object-Relational Mapping ● Mapping from classes to tables in an RDBMS.

– Storing of objects in a database.– Encapsulating database entities in objects.

● An object-relational mapper is a bridge between the database and the application.– The programmer does not need to formulate SQL

queries.– When the data model gets changed the

corresponding classes are automatically updated.

– When the application gets migrated to another RDBMS only the configuration needs to be changed.

Page 21: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Propel ● Propel is such a bridge for PHP 5.

– Follows the design of Apache Torque.

● Two components:– Propel Generator (uses Phing)

● Input: XML specification for the data model.● Output: Database Schema and PHP classes.

– Propel Runtime (uses Creole)● Runtime Environment.● Framework for the use of the classes generated by the

Propel Generator.

● Installation– pear install http://propel.phpdb.org/pear/propel_runtime-current.tgz– pear install http://propel.phpdb.org/pear/propel_generator-current.tgz

Page 22: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Data Model

Page 23: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Data Model

Page 24: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Object Model ● Table author

– Abstract base class BaseAuthor.● Methods like

– getFirstName() or– setFirstName($v).

– Concrete class Author extends BaseAuthor.● Empty.● Will not be overwritten if the Propel Generator is run

again.

Page 25: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Creating a Book

Page 26: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Agavi ● Framework for building PHP applications

based on the Model-View-Conrtroller design pattern.– Think „PHP on Rails“.

● Uses Phing.● Can use Propel for the Model.

● Installation

– pear install http://propel.phpdb.org/pear/propel_runtime-current.tgz– pear install http://propel.phpdb.org/pear/propel_generator-current.tgz

Page 27: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Conclusion ● „PHP is like the Borg in Star Trek – it adds

the skills of others to its own feature set to attain perfection.“ (Kristian Köhntopp)

● PHP is designed to integrate libraries easily and make their functionality available in the language.

● With the new language features of version 5, PHP has now reached a level that allows for the „assimilation of paradigms“ in addition to the „assimilation of functionality“.

Page 28: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Conclusion ● Java

– „Lean core, rich library“.– Rather tool-centric development.

● Code Generators, Frameworks, ...

● PHP– „Rich core, lean infrastructure“.– Many convenience functions.

● Even peripheral functionality is available as native functions (that wrap libraries, for instance).

– Supports tool-centric approach in PHP 5.

Page 29: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Conclusion ● Developer-Centric Approach

– Example: PDO and Session Management.● Database Abstraction and Session Management as

core components of the interpreter (and thus integral parts of the language).

● Tool-Centric Approach– Example: Propel

● Abstraction / Integration through Code Generation.● The application is manipulated on the tool-level – with

the tool.

Page 30: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/

Commercial ● PHPUnit Pocket Guide.● O'Reilly Media, 2005.● ISBN: 0-596-10103-1.

Page 31: PHP 5 - The Year Afterconferences.oreillynet.com/.../bergmann_PHP_5.pdf · Standard PHP Library (SPL). Extensions like DOM and MySQLi offer APIs for OOP. – Good support for working

License ● These slides are available under the Creative Commons

Attribution-NoDerivs-NonCommercial 2.0 license.● You are free to copy, distribute, display, and perform the

work under the following conditions:– Attribution: You must give the original author credit.– Noncommercial: You may not use this work for commercial

purposes.– No Derivative Works: You may not alter, transform, or build

upon this work.– For any reuse or distribution, you must make clear to others

the license terms of this work.– Any of these conditions can be waived if you get permission

from the author.● Your fair use and other rights are in no way affected by the

above.

„PHP 5 – The Year After“Sebastian Bergmannhttp://www.sebastian-bergmann.de/talks/