using php and soa for situational applications in the enterprise

29
© 2006 IBM Corporation New York PHP Conference & Expo 2006 ® 1 Using PHP and SOA for Situational Applications in the Enterprise Mike Burr [email protected] Senior Developer WebSphere Technology Institute IBM

Upload: webhostingguy

Post on 12-Jul-2015

2.134 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Using PHP and SOA for Situational Applications in the Enterprise

© 2006 IBM Corporation

New York PHP Conference & Expo 2006

®

1

Using PHP and SOA for Situational Applications in the Enterprise Mike [email protected] DeveloperWebSphere Technology InstituteIBM

Page 2: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 20062

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?

Page 3: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 20063

Application Landscape Overview

Situational / Opportunistic

Applied to a new or still-changing environments

Focus on effectiveness

Key metrics: time-to-productive-use, good-enough

Lifespan expectation: short

Basis: mostly Information Delivery, some Business Process

Source: situated design / custom development

Decision Maker: partnership, primarily LOB

Systematic / Operational

Applied to stable, well-understood environments

Focus on efficiency

Key metrics: cost / ROI, performance, error-free, secure

Lifespan expectation: long-lived

Basis: mostly Transactional, some Business Process

Source: packaged software, minor modification, a few custom

Decision Maker: partnership, primarily IT (In-

House or Bus Partner)

Growth in # of Apps

Page 4: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 20064

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

Page 5: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 20065

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.

Page 6: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 20066

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.

Page 7: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 20067

Training Tracker architecture

Training

Tracker

Employee

directory

Education

service

corporate network

internet

Page 8: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 20068

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.

Page 9: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 20069

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

Page 10: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200610

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);

?>

Page 11: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200611

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];

Page 12: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200612

// 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);

Page 13: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200613

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

Page 14: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200614

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;

...

Page 15: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200615

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);

}

}

}

}

Page 16: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200616

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

?

Page 17: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200617

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)

3. Install script collects configuration information and

inspects/modifies environment to complete install

4. User performs some manual steps (e.g. cleanup install

directory) to indicate install/configuration is complete

install.php

config.php

Page 18: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200618

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

Page 19: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200619

Proposed solution

Use PHPDoc tags to flag variables that need

to be set to configure the application.

Packaging tool that collects the following into

an application archive file:

application files (scripts and static content)

database schema and initial data

install.php script generated from PHPDoc

tags

information about PEAR/PECL libraries

needed and php.ini settings

.html,

.gif,… .php

install.php

pa

cka

gin

g

too

l

.tar.gz

PEAR/PECL and

php.ini info

Page 20: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200620

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;

Page 21: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200621

Training Tracker install.php example

Page 22: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200622

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

Page 23: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200623

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.)

Page 24: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200624

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

Page 25: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200625

QoS Dynamically adjust number

of instances of application

in response to demand and

administrative policy

Impact of application on

enterprise services can be

measured, monitored and

controlled

Access to application can

be controlled and audited

for regulatory or billing

purposes

Training

Tracker

Employee

directory

Training

Tracker

Training

Tracker

Core

enterprise

app

SPEED

LIMIT

20

SPEED

LIMIT

20

SPEED

LIMIT

70

Page 26: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200626

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.

Page 27: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200627

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)

Page 28: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200628

Page 29: Using PHP and SOA for Situational Applications in the Enterprise

New York PHP Conference & Expo 200629

Thanks!

If you have any questions or would like to get in touch

with me, my email address is:

[email protected]