2. Goals
Explore how PHP best fits in the enterprise. What
works well, what doesn’t, what needs to be fixed?
Propose some technologies, tools and approaches
that we believe will help PHP reach its full potential in
the enterprise environment.
Get feedback from the PHP community. Do you think
we’re on the right track?
2
New York PHP Conference & Expo 2006
3. Application Landscape Overview
Growth in # of Apps
Systematic / Operational Situational / Opportunistic
Applied to stable, well-understood environments Applied to a new or still-changing environments
Focus on efficiency Focus on effectiveness
Key metrics: cost / ROI, performance, error-free, Key metrics: time-to-productive-use, good-
secure enough
Lifespan expectation: long-lived Lifespan expectation: short
Basis: mostly Transactional, some Business Basis: mostly Information Delivery, some
Process Business Process
Source: packaged software, minor modification, a Source: situated design / custom development
few custom Decision Maker: partnership, primarily LOB
Decision Maker: partnership, primarily IT (In-
House or Bus Partner)
3
New York PHP Conference & Expo 2006
4. Shifting focus
Enterprise IT has traditionally focused toward the systematic end of
the spectrum, but several forces are pushing them to incorporate
the entire spectrum into their thinking:
Increasing speed of business is translating to immediate need
and shorter expected lifespan for applications.
Difficulty adapting current IT processes and methodologies that
assume greater up-front investment in application and
amortization over long application lifespan.
New technologies enabling classes of applications with real
business value that are a better match for the technologies at
the situational app end of the spectrum (e.g. mashups).
Economies of scale from consolidating infrastructure used to
deploy situational apps
Need to audit application use of data, e.g. for governmental
regulations
4
New York PHP Conference & Expo 2006
5. PHP and SOA
The combination of PHP and SOA is a good solution for these
situational applications, but there are gaps between enterprise IT
and PHP that need to be addressed to allow PHP to be an equal
player in the enterprise IT space:
Programming model
Development and deployment model
Management model
Enterprise class QoS
BUT…we must not destroy the things that make PHP appealing in
the process of addressing these gaps.
5
New York PHP Conference & Expo 2006
6. Training Tracker
As an example, consider the needs of the
accounting department in a large
enterprise that needs to put all its
employees through a training program
offered by an external vendor to make the
employees aware of some recently
established accounting rules. The
accounting department would like a
Training Tracker application that allows
employees to enroll and schedule their
training and managers to track the
successful completion of training by all
their employees.
6
New York PHP Conference & Expo 2006
7. Training Tracker architecture
Training
Tracker
internet
corporate network
Education
service
Employee
directory
7
New York PHP Conference & Expo 2006
8. Programming Model for PHP Enterprise
Applications
Be simple and thus enable developers who have a much better
understanding of business issues as compared to IT issues.
Insulate the developer from underlying SOA implementation
technologies, such as XML, WSDL, SOAP and REST.
Provide a unified API for data from various data sources in a
SOA environment, such as XML, databases and legacy
applications.
Provide a unified API for invoking different types of service
implementations in a SOA environment, such as REST and
SOAP.
8
New York PHP Conference & Expo 2006
9. SDO (Service Data Objects)
The bundle of technology called SDO is comprised of:
APIs for working with the data in an individual SDO
APIs for creating SDOs, hooking them into a graph, unsetting them…
An XML DAS: a handful of lines of code to get data from XML and turn it
into a graph of SDOs, one line to write it back out
Like DOM but a lot easier to use
A handful of lines to get data from a relational database and turn it into a
graph of SDOs, one line to write it back
Work with the data in the same way regardless of source
A graph of SDOs is disconnected from the data source but retains a
change history and a copy of its initial values (enables optimistic offline
lock – see Fowler "Patterns of Enterprise Application Architecture")
Readily serialised and un-serialised – hence a preferred way to move
structured data around in distributed (SOA) applications
9
New York PHP Conference & Expo 2006
10. Training Tracker SDO example
<?php
/*****************************************************************
* METADATA DEFINING THE DATABASE
******************************************************************/
$training_table = array (
'name' => „training',
'columns' => array(„empid', „trainingDate'),
'PK' => „empid'
);
$database_desc = array($training_table);
?>
10
New York PHP Conference & Expo 2006
11. require_once 'SDO/DAS/Relational.php';
/***************************************************************
* Construct the DAS with the metadata
***************************************************************/
$das = new SDO_DAS_Relational($database_desc);
/**************************************************************
* Get a database connection
***************************************************************/
$dbh = new PDO(PDO_DSN, DATABASE_USER, DATABASE_PASSWORD);
/**************************************************************
* Issue a query to obtain an object for a row
***************************************************************/
$pdo_stmt = $dbh->prepare('select empid, trainingDate from training where empid=?');
$root = $das->executePreparedQuery($dbh, $pdo_stmt, array($empid));
$training = $root->training[0];
11
New York PHP Conference & Expo 2006
12. // Mary has scheduled her training
$training->trainingDate = “June 23, 2006”;
require_once 'SDO/DAS/Relational.php';
/**************************************************************
* Construct the DAS with the metadata and get a connection
***************************************************************/
$das = new SDO_DAS_Relational($database_desc);
$dbh = new PDO(PDO_DSN, DATABASE_USER, DATABASE_PASSWORD);
/**************************************************************
* Write the updates to the database. $root is the original root
* data object returned during retrieval of the training information.
***************************************************************/
$das->applyChanges($dbh, $root);
12
New York PHP Conference & Expo 2006
13. SCA (Service Component Architecture)
Simplifies application assembly by resolving references
to other components and services at runtime
Uses SDO to simplify working with complex XML data
structures on Web service calls
Simplifies writing components which can be called
locally or remotely (via Web services)
Automatically generates WSDL definitions from
annotations within the script
13
New York PHP Conference & Expo 2006
14. Training Tracker Component
Training Tracker component aggregates the other services
and database information
/**
* @service
*/
class TrainingTracker {
/**
* @reference http://empdir.mycompany.com/empdir.wsdl
*/
$empdir;
/**
* @reference http://websvc.we-teach.com/courseschedule.wsdl
*/
$courses;
...
14
New York PHP Conference & Expo 2006
15. Training Tracker Component (continued)
function showStatus($manager) {
foreach ($empdir->reportsTo($manager) as $employee) {
// fetch training record for $employee->id as shown in
// SDO example above
if ($training->trainingDate) {
print $employee->name.”:”.$training->trainingDate;
}
else {
print $employee->name.”: training still available on”.
$courses->datesAvailable(COURSE);
}
}
}
}
15
New York PHP Conference & Expo 2006
16. Development and Deployment Model
Developing an application is only part of the problem.
How do you make an application available to users?
Staged mode – copy application artifacts from development
environment to production environment
Direct mode – use the same environment for both development
and production
?
16
New York PHP Conference & Expo 2006
17. The Packaging and Installation Problem
Packaging of PHP applications today is ad-hoc.
Many of the more mature PHP applications
seem to be converging on a common pattern:
1. Application files packaged as .zip or .tar.gz archive
2. Users extract archive, then point web browser to
application install script (e.g. install.php)
install.php
3. Install script collects configuration information and
inspects/modifies environment to complete install
config.php
4. User performs some manual steps (e.g. cleanup install
directory) to indicate install/configuration is complete
17
New York PHP Conference & Expo 2006
18. Proposed solution
Solution needs to minimally ensure the following:
consistent settings in the PHP environment (php.ini)
database has the correct schema and all the pre-
loaded data that the application depends on
constants in the PHP application scripts that are used
for things like establishing database connections,
writing to temporary storage, etc. are set
correct set of PEAR and PECL libraries (with the right
versions) are available
18
New York PHP Conference & Expo 2006
19. Proposed solution
.html,
Use PHPDoc tags to flag variables that need .gif,… .php
to be set to configure the application.
PEAR/PECL and
Packaging tool that collects the following into php.ini info
an application archive file:
application files (scripts and static content) install.php
database schema and initial data
packaging
tool
install.php script generated from PHPDoc
tags
information about PEAR/PECL libraries
needed and php.ini settings .tar.gz
19
New York PHP Conference & Expo 2006
20. Training Tracker install.php example
/**
* Database password
*
* Set the value to the password used to access the Training Tracker
* database.
*
* @install
*/
define('DATABASE_PASSWORD', 'mydbpassword');
/**
* Some other variable
*
* This text would describe what myvar is used for and how the administrator
* should determine what to set it to.
*
* @global integer $GLOBALS['othervar']
* @install
*/
$GLOBALS['othervar'] = 42;
20
New York PHP Conference & Expo 2006
22. Management model
PHP developers like advantages of “under the desk” deployment:
Simple to monitor app and correct operational problems as
necessary
Application trivially upgraded to handle bug fixes,
enhancements and new requirements
But this model does not match the needs of enterprise IT
department:
No ability to monitor or manage application and its impacts on
other IT infrastructure (use of enterprise services, for example)
Limited/no ability to track application usage for billing and
regulatory compliance purposes
No ability to assess backup and security provisions for
application
22
New York PHP Conference & Expo 2006
23. Private Virtual Servers
Modeled after PHP hosting provided by ISPs
PHP developer requests virtual PHP server from
enterprise IT
Server is hosted on IT infrastructure; developer uses
web-based console and WebDAV to access
Includes database space and simplified access to
enterprise services (code snippets, preconfigured
client code, etc.)
23
New York PHP Conference & Expo 2006
24. Benefits
Developer
essentially the same experience as with a local
LAMP stack
gets enterprise-level backup, failover, security and
support
IT
gains ability to monitor and manage application
distributed shared caching
simplified migration path when situational
applications become strategic
24
New York PHP Conference & Expo 2006
25. QoS
Dynamically adjust number
of instances of application
Training
Tracker Training in response to demand and
Tracker
administrative policy
Training
Tracker
Impact of application on
enterprise services can be
measured, monitored and
SPEED SPEED
LIMIT LIMIT
controlled
20 20
Core Access to application can
enterprise SPEED be controlled and audited
LIMIT
app
70 Employee for regulatory or billing
directory
purposes
25
New York PHP Conference & Expo 2006
26. Conclusion
The combination of PHP and SOA has the potential to
address the rapidly-expanding need for situational
applications in the enterprise. With a few carefully
crafted changes, PHP and enterprise IT can converge
in a way that lets users capitalize the strengths of
each.
26
New York PHP Conference & Expo 2006
27. Further reading
PHP topics on developerWorks
http://www-128.ibm.com/developerworks/opensource/top-projects/php.html
SDO
http://www-128.ibm.com/developerworks/library/os-sdophp/
http://www-128.ibm.com/developerworks/opensource/library/os-php-sdo/
http://www.php.net/manual/en/ref.sdo.php
SCA
http://www-128.ibm.com/developerworks/library/specification/ws-sca/ (although
we expect PHP SCA will be much simpler than the Java and C++ examples
you see here)
27
New York PHP Conference & Expo 2006
29. Thanks!
If you have any questions or would like to get in touch
with me, my email address is:
burrm@us.ibm.com
29
New York PHP Conference & Expo 2006