#2078
 Extending and Integrating Popular PHP Applications with
 IBM WebSphere® sMash

Rob Nicholson,     IBM Senior Techni...
Abstract
IBM WebSphere® sMash is a platform for developing and running agile
  Web applications using scripting languages ...
Agenda

•   WebSphere sMash
•   PHP in WebSphere sMash
•   PHP Applications
•   Demonstrations




                       ...
Agenda

•   WebSphere sMash
•   PHP in WebSphere sMash
•   PHP Applications
•   Demonstrations




                       ...
WebSphere sMash
Agile development of dynamic Web 2.0 based applications
                                      Introducing
...
WebSphere sMash
             Dynamic scripting languages
Speed        Templates & Pre-built services


             Visual...
WebSphere sMash Tooling
                                       Visual Flow Editor

                    Visual UI Editor


...
Agenda

•   WebSphere sMash
•   PHP in WebSphere sMash
•   PHP Applications
•   Demonstrations




                       ...
Why PHP?
•   20M+ web domains use PHP
•   3M+ Programmers know PHP
•   Huge repository of reusable modules, snippets, exte...
WebSphere sMash PHP Support
• PHP runtime built in Java.
  –To PHP.net as Jruby is to Ruby and Jython is to Python
• Compi...
PHP in WebSphere sMash
         Java Virtual Machine
                                                               • Runs...
Benefits of PHP in sMash.
• Develop quickly by using the best tools and
  materials for the job.
  – PHP code such as smar...
PHP – Java/Groovy Interaction
•PHP Java/Groovy Bridge allows PHP to:
 – Instantiate Java Classes
 – Call static and instan...
PHP – Java Bridge – Basic use
                                  Basic access to Java
                               method...
PHP- Java Bridge – Iterators and overloads
                         Bridging between PHP and Java iterators



           ...
Java Bridge – Importing Java Classes.


                      Importing a Java class creates a PHP
                       ...
Java Bridge – Extending Java in PHP
                                   Extending a Java class inside PHP is
              ...
Groovy Bridge – Importing Scripts




                                                      18
                           ...
Other Groovy Bridge Features

• Method and Field Access
• Closures and Curry
  – PHP Functions can be passed to Groovy as ...
Invoking PHP - Events

• PHP Event Handler examples:
  – Timer
  – Custom Event
  – Flow, Security or Connection event.
  ...
Invoking PHP - Script Activity in Flow




                                                       21
                     ...
Agenda

•   WebSphere sMash
•   PHP in WebSphere sMash
•   PHP Applications
•   Demonstrations




                       ...
PHP Applications that run on sMash
       Forums                    Ajax
                wiki
                            ...
ZSL develops Web 2.0 Assets 3x faster with
WebSphere sMash
Downloaded sMash DE from projectzero.org
Assets built in 3½ wee...
Energy Commons Overview
www.energycommons.com
• Concept
  – Standardized, private labeled social networking
    applicatio...
Energy Commons Architecture Overview




                                                       26
                       ...
SugarCRM Integration scenario



                           MQ




                           MQ




                     ...
Demonstrations




                                          28
                 © 2009 IBM Corporation
Agenda

•   WebSphere sMash
•   PHP in WebSphere sMash
•   PHP Applications
•   Demonstrations




                       ...
30
© 2009 IBM Corporation
References
• WebSphere sMash site http://www.projectzero.org/

• WebSphere sMash forums http://www.projectzero.org/forum/
...
We love your Feedback!
• Don’t forget to submit your Impact session and
  speaker feedback! Your feedback is very
  import...
© IBM Corporation 2009. All Rights Reserved.

The workshops, sessions and materials have been prepared by IBM or the sessi...
Upcoming SlideShare
Loading in …5
×

IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular PHP Applications with IBM WebSphere sMash

4,700 views

Published on

Session 2078 at IBM IMPACT 2009 Conference.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,700
On SlideShare
0
From Embeds
0
Number of Embeds
277
Actions
Shares
0
Downloads
44
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • <number>
  • <number>
  • <number>
  • Java Virtual Machine based runtime supporting PHP and Groovy.NOT a Java EE environmentTargeted at Script developersNot for producing Java code.A Commercial ProjectWith development done in the open and limited no-cost use.A Full Stack RuntimeWith a HTTP server, module system and simple IDE built in.IBM’s Scripting platform.For building Agile Web ApplicationsUsing PHP and GroovyUsing assets from PHP and Java worlds.Built on Java (SE not EE)Uses many LAMP principles.Single threaded application programming model.Shared nothing.Restart-able runtime.
  • WebSphere sMash core values are Speed, Simplicity, and Agility- product elements that support this are:SpeedDynamic scripting languages (PHP and Groovy – with Java as system language)Core application constructs: templates, pre-built servicesSimplicityBuilt-In development tooling: Visual Editors for Web Page Construction and for Flow AssemblyAssemble-style development (Developers can visually mash up services and feeds using a Visual Editor for Flow Assembly)AgilitySimple deployment (application “is” the server)Runtime Characteristics (clean, cost effective, short-lived)
  • Dynamic Scripting Editor – Groovy / PHPVisual UI Editor - Constructing web pages (Javascript)Visual Assembly Editor - Scripting / assembling activities into a flow<number>
  • <number>
  • Why is IBM interested in PHP? 3 Reasons: Community, Assets, SimplicityCommunity: The PHP community is around 3M programmers. (Java community is around 7M programmers). Assets: Lots of applications and snippets that can be easily re-used. Validated by sMash partners ZSL, SugarCRM.Simplicity: The language is very easy to learn even for people without traditional programming skills.But don’t be fooled. PHP is not a toy language. 1/3 of the internet uses it. It powers Yahoo, facebook and wikipedia and commercial applications such as SugarCRM.
  • OK, so PHP is interesting…..but why not use the existing C based implementation. Why implement it on the JVM?Well, we wanted to be able to build sMash using Java but give PHP programmers a first rate programming experience.Since the PHP is built on the JVM, PHP , Groovy and Java can interact without costly IPC. Interaction on the same callstack.PHP can reach into the Global context without copying.This allows PHP programmers to leverage the power of the Java libraries and Java/Groovy programmers to re-use all the great applications and snippets from the PHP world.It really is the best of both worlds. We have multiple cases of business partners combining PHP assets with new code written in Groovy.We have instances of business partners mixing Java and Groovy programmers on the same project.Its about getting the job done…….fast……using what you have.Add to this all the great Java technology which we’ve invested 100s of PY in. Its pretty exciting to think about the Java JIT being able to chew on PHP code.IBM is not alone in this. At Javaone this year there were multiple presentations on the merits of bringing new languages to the Java Platform. Jruby, Jython, Groovy, Scala are just a few of the languages with large followings.11
  • The PHP runtime is built on the JVM. It requires Java 5 SE or later from any vendor.The HTTP interface is via Zero. We are not using apache or lightppd here.PHP Scripts are parsed into an intermediate form and then either interpreted or compiled to Java Bytecodes.Java Bytecodes are cached in memory and written to disk as .class files.User experience is one of scripting (compilation is hidden from user).PHP extensions implemented in C from php.net can be attached via XAPI-C which uses JNI.We also attach Java extensions using XAPI-J which is how we interface to Zero and to databases via JDBC.We have a debug port to allow Eclipse PDT to debug PHP scripts.IF anyone asks about performance (suggest not to bring this up)…….PHP performance is great for most sMash use cases. The pathlength is not in the PHP its in the database, webserver and infrastructure.For huge deployments of PHP applications where out and out throughput matters, PHP performance is about 50% of PHP.net default configuration.Its important to say “default configuration” because PHP.net users can download and install a bytecode cache with improves throughput by about 4X.The implementation we have in sMash 1.1 has 2X the pure interpreter thoughout from sMash 1.0.Its still mainly an interpreter. We have designs and work items for sMash 2.0 and beyond to generate much more efficient bytecodes.
  • OK, so what does this PHP to java interaction look like?Well there are really two schemes. For tight coupling we can use the java bridge which allows PHP to instantiate classes, call methods, extend java classes etc.This is appropriate when wanting to re-use java libraries, such as SugarCRM’s desire to use Apache libraries from their PHP application.Also one can leverage the Zero programming models to design handlers that interact using events and the Global Context.This more appropriate for ZSL’s use case where they want to mix PHP code with new handlers written in Groovy.There is also the extension interface we saw earlier of course. This allows the creation of PHP extension functions and object proxies in Java.
  • <number>
  • <number><number>
  • How long implementation may takeHow many resourcesRolesHardware/software requirementsTypical project plan; first step; milestonesPitfalls; exception plan<number>
  • <number>
  • <number>
  • <number>Change and Release Management for Software Development<number>
  • http://www.ibm.com/developerworks/offers/techbriefings/<number>
  • IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular PHP Applications with IBM WebSphere sMash

    1. 1. #2078 Extending and Integrating Popular PHP Applications with IBM WebSphere® sMash Rob Nicholson, IBM Senior Technical Staff Member © 2009 IBM Corporation
    2. 2. Abstract IBM WebSphere® sMash is a platform for developing and running agile Web applications using scripting languages and Web 2.0 technologies such as RESTful Web services, JavaScript Object Notation, and Atom and RSS feeds. It supports the Groovy language, familiar to Java programmers, and PHP for access to thousands of PHP applications and libraries,and the huge PHP developer community. IBM WebSphere sMash is focused on significant improvement in time-to- value for Situational Applications and Mashups. Partners and community have found that by combining PHP applications and libraries with new code written in PHP or Groovy for the IBM WebSphere sMash platform, they can achieve significant reduction in development time for Situational Applications and Mashups. We cover an overview of the PHP support in IBM WebSphere sMash and the support for generating new PHP code before exploring more detailed scenarios demonstrating PHP Applications being extended, integrated and mashed up. 2 © 2009 IBM Corporation
    3. 3. Agenda • WebSphere sMash • PHP in WebSphere sMash • PHP Applications • Demonstrations 3 © 2009 IBM Corporation
    4. 4. Agenda • WebSphere sMash • PHP in WebSphere sMash • PHP Applications • Demonstrations 4 © 2009 IBM Corporation
    5. 5. WebSphere sMash Agile development of dynamic Web 2.0 based applications Introducing WebSphere sMash • Improves developer productivity and efficiency through the support of dynamic scripting languages (Groovy and PHP) on Java • Leverages Web 2.0 technologies for service invocation, service composition and data interchange • Provides visual tools for developers to build and assemble web2.0 applications 5 © 2009 IBM Corporation
    6. 6. WebSphere sMash Dynamic scripting languages Speed Templates & Pre-built services Visual Editors Simplicity Assemble style development Application “is” the server Agility Clean, short-lived runtime 6 © 2009 IBM Corporation
    7. 7. WebSphere sMash Tooling Visual Flow Editor Visual UI Editor Dynamic Scripting Editor 7 © 2009 IBM Corporation
    8. 8. Agenda • WebSphere sMash • PHP in WebSphere sMash • PHP Applications • Demonstrations 8 © 2009 IBM Corporation
    9. 9. Why PHP? • 20M+ web domains use PHP • 3M+ Programmers know PHP • Huge repository of reusable modules, snippets, extensions. • Easy language to learn -> Mashups • Language has evolved to be easy to use Gartner (Dec 2007) TIOBE Programming Community Index (Sep 2008) • PHP Developers to grow from 3 to 5.5 million by 2013 • PHP Developers in Commercial or Corporate IT to grow from 13% to 60% by 2013 • “Pay special attention to opportunities to leverage PHP in combination with Java development efforts” 9 © 2009 IBM Corporation
    10. 10. WebSphere sMash PHP Support • PHP runtime built in Java. –To PHP.net as Jruby is to Ruby and Jython is to Python • Compile PHP into Java bytecodes and run on a Java Virtual Machine. • Powerful blending of PHP and Java code. –Java and PHP code run in the same process on the same Thread • No need for Inter-process communication. –Efficient calls between PHP, Java, Groovy on the same stack. –Pass data between Java, Groovy and PHP without copying. • Avoids serialising and passing data between processes. –Import Java classes as PHP Classes • Easy access to the many Java libraries from PHP code. 10 © 2009 IBM Corporation
    11. 11. PHP in WebSphere sMash Java Virtual Machine • Runs PHP 5 scripts • Requires Java 5 SE or later. HTTP server • Extensibility via XAPI Zero Programming Model • XAPI-C for C extensions from php.net • XAPI-J for Java extensions, native libraries invoked over JNI and Project Zero Java- Bridge JAR interface PHP runtime JAR Groovy Debug • Extension language choice opaque to P8 Runtime JAR runtime PHP script Interpreter/Compiler JAR • Java Bridge xd XAPI-J eb • Debug using via xdebug protocol using XAPI-C Java ug C Eclipse with PDT Extensions Extensions WebSphere sMash PDT2 11 © 2009 IBM Corporation
    12. 12. Benefits of PHP in sMash. • Develop quickly by using the best tools and materials for the job. – PHP code such as smarty, SimpleXML, drupal, phpBB, – Java code such as Apache Lucene, POI and Eclipse BIRT • Start simple using sMash tooling such as ZRM, Flow – Customise and extend using PHP scripts and snippets • Unleash agile teams using Java and PHP skills. – Allow teams to use their full range of skills. • Build on a solid base. – PHP built on the Java VM at the heart of IBM’s enterprise software stack. • Familiar to many enterprises. • Vast investment in JIT, Garbage Collector, RAS and tools. 12 © 2009 IBM Corporation
    13. 13. PHP – Java/Groovy Interaction •PHP Java/Groovy Bridge allows PHP to: – Instantiate Java Classes – Call static and instance methods – Access static and instance fields – Extend Java Classes (not abstract) – Implement Java Interfaces. – Interact with Groovy Classes objects, Closures and Ranges •Zero programming model allows PHP to: – Interact with other Modules built using Groovy, Java, PHP, Flow by: • Handle and fire Zero events • Fetch and store to the global context. 13 © 2009 IBM Corporation
    14. 14. PHP – Java Bridge – Basic use Basic access to Java methods and fields - types are automatically converted at boundary of PHP runtime Static methods and fields are accessible by using the built in JavaClass class Java exceptions can be caught in PHP scripts 14 © 2009 IBM Corporation
    15. 15. PHP- Java Bridge – Iterators and overloads Bridging between PHP and Java iterators Signatures provide explicit control for overloaded constructors and methods 15 © 2009 IBM Corporation
    16. 16. Java Bridge – Importing Java Classes. Importing a Java class creates a PHP class that has the same shape 16 © 2009 IBM Corporation
    17. 17. Java Bridge – Extending Java in PHP Extending a Java class inside PHP is possible but has some limitations Java bean access maps field access onto get/set method calls 17 © 2009 IBM Corporation
    18. 18. Groovy Bridge – Importing Scripts 18 © 2009 IBM Corporation
    19. 19. Other Groovy Bridge Features • Method and Field Access • Closures and Curry – PHP Functions can be passed to Groovy as a closure. 19 © 2009 IBM Corporation
    20. 20. Invoking PHP - Events • PHP Event Handler examples: – Timer – Custom Event – Flow, Security or Connection event. – Standard Request Event 20 © 2009 IBM Corporation
    21. 21. Invoking PHP - Script Activity in Flow 21 © 2009 IBM Corporation
    22. 22. Agenda • WebSphere sMash • PHP in WebSphere sMash • PHP Applications • Demonstrations 22 © 2009 IBM Corporation
    23. 23. PHP Applications that run on sMash Forums Ajax wiki Debugging FirePHP CRM Desktop Content Virtualisation Management Blogging 23 © 2009 IBM Corporation
    24. 24. ZSL develops Web 2.0 Assets 3x faster with WebSphere sMash Downloaded sMash DE from projectzero.org Assets built in 3½ weeks Junior web development team Dynamic Scripting Skills Web Development Focus Know very little about .Net and JEE Understand concepts and functioning of Web Services, but may not have built or deployed them. 67% reduction in time-to-market for developing Web 2.0 assets 90% less time to implement best-of-breed programs Ability to reuse 25% of code Out-of-the-box functionality vs. 2½ days to install comparable software 24 © 2009 IBM Corporation
    25. 25. Energy Commons Overview www.energycommons.com • Concept – Standardized, private labeled social networking application offering targeted at businesses, consumers, and inter company collaboration on the energy topic • Value Proposition – Interconnection of parties for knowledge share and exchange on demand in a silo’d industry through shared cost model for development and operations • Innovative Aspects – Interconnected portals through “hub and spoke” utilizing global reach, large ecosystem, and utility channel to create scale – Viral expansion into energy value chain – Incentive Finder for Data Center incentives – 24x7 advertisement for IBM as global innovator for energy and climate 25 © 2009 IBM Corporation
    26. 26. Energy Commons Architecture Overview 26 © 2009 IBM Corporation
    27. 27. SugarCRM Integration scenario MQ MQ 27 © 2009 IBM Corporation
    28. 28. Demonstrations 28 © 2009 IBM Corporation
    29. 29. Agenda • WebSphere sMash • PHP in WebSphere sMash • PHP Applications • Demonstrations 29 © 2009 IBM Corporation
    30. 30. 30 © 2009 IBM Corporation
    31. 31. References • WebSphere sMash site http://www.projectzero.org/ • WebSphere sMash forums http://www.projectzero.org/forum/ • Developers Guide Documentation. http://www.projectzero.org/documentation/ • PHP Applications that run on sMash: http://www.projectzero.org/blog/index.php/2008/10/29/documenting-php-applications-that-run-on- smash/ 31 © 2009 IBM Corporation
    32. 32. We love your Feedback! • Don’t forget to submit your Impact session and speaker feedback! Your feedback is very important to us, we use it to improve our conference for you next year. • Go to www.impact09guide.com on a smartphone device or a loaner device • From the Impact 2009 Online Conference Guide; – Select Agenda – Navigate to the session you want to give feedback on – Select the session or speaker feedback links – Submit your feedback 32 © 2009 IBM Corporation
    33. 33. © IBM Corporation 2009. All Rights Reserved. The workshops, sessions and materials have been prepared by IBM or the session speakers and reflect their own views. They are provided for informational purposes only, and are neither intended to, nor shall have the effect of being, legal or other guidance or advice to any participant. While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this presentation or any other materials. Nothing contained in this presentation is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in this presentation may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results. Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will experience will vary depending upon many factors, including considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve results similar to those stated here. All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer. The following are trademarks of the International Business Machines Corporation in the United States and/or other countries: ibm.com/legal/copytrade.shtmlAIX, CICS, CICSPlex, DataPower, DB2, DB2 Universal Database, i5/OS, IBM, the IBM logo, IMS/ESA, Power Systems, Lotus, OMEGAMON, OS/390, Parallel Sysplex, pureXML, Rational, Redbooks, Sametime, SMART SOA, System z , Tivoli, WebSphere, and z/OS. A current list of IBM trademarks is available on the Web at “Copyright and trademark information” at ibm.com/legal/copytrade.shtml. Adobe, the Adobe logo, PostScript, and the PostScript logo are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States, and/or other countries. IT Infrastructure Library is a registered trademark of the Central Computer and Telecommunications Agency which is now part of the Office of Government Commerce Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both. ITIL is a registered trademark, and a registered community trademark of the Office of Government Commerce, and is registered in the U.S. Patent and Trademark Office Intel and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. UNIX is a registered trademark of The Open Group in the United States and other countries. Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. 33 © 2009 IBM Corporation

    ×