An Introduction to Websphere sMash for PHP Programmers

10,119 views
9,479 views

Published on

IBM® WebSphere® sMash is an agile Web application platform for developing and running modern Web applications. It introduces a simple environment for creating, assembling and running applications based on popular Web technologies.

This presentation was delivered at the Dutch PHP Conference 2009. It shows how the PHP support in sMash can be used to easily integrate with Java assets.

For more information, see http://projectzero.org

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

No Downloads
Views
Total views
10,119
On SlideShare
0
From Embeds
0
Number of Embeds
72
Actions
Shares
0
Downloads
78
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

An Introduction to Websphere sMash for PHP Programmers

  1. An Introduction to IBM WebSphere sMash for PHP Programmers Jonathan Lawrence & Robin Fernandes Software Developers, WebSphere Development, IBM projectzero.org
  2. Agenda <ul><li>Overview of WebSphere sMash </li></ul><ul><li>Simple sMash demonstration </li></ul><ul><li>PHP in sMash </li></ul><ul><li>PHP sMash demonstration </li></ul><ul><li>Summary and Questions </li></ul>
  3. What is WebSphere sMash? <ul><li>WebSphere sMash is a new Agile Web Application Platform </li></ul><ul><ul><li>Exploiting Dynamic Scripting Languages </li></ul></ul><ul><ul><li>Optimized for producing... </li></ul></ul><ul><ul><ul><li>REST-based Services </li></ul></ul></ul><ul><ul><ul><li>Integration Applications </li></ul></ul></ul><ul><ul><ul><li>Mash-ups </li></ul></ul></ul><ul><ul><ul><li>Rich Web Interfaces </li></ul></ul></ul><ul><ul><li>Architected for... </li></ul></ul><ul><ul><ul><li>Speed, Simplicity & Agility </li></ul></ul></ul>
  4. What is WebSphere sMash? <ul><li>Java TM Virtual Machine based runtime supporting PHP and Groovy. </li></ul><ul><ul><li>NOT a Java EE environment </li></ul></ul><ul><li>Targeted at Script developers </li></ul><ul><ul><li>Not for producing Java code. </li></ul></ul><ul><li>A Commercial Project </li></ul><ul><ul><li>With development done in the open and limited no-cost use. </li></ul></ul><ul><ul><li>Download for free at http://projectzero.org . </li></ul></ul><ul><li>A Full Stack Runtime </li></ul><ul><ul><li>With a HTTP server, module system and simple IDE built in. </li></ul></ul>
  5. WebSphere sMash for the application long tail Usage Number of Applications Java Enterprise Edition For business department and mid-market customers looking for rapidly developed agile applications, short implementation cycles and ways to easily reuse existing investments. Time to value is more important than enduring value Strategic, long-lived applications Dynamic Scripting Application Server
  6. Accelerate business and IT alignment Speed Simplicity Agility Dynamic scripting languages Templates & pre-built services No-charge, robust browser & Eclipse based tooling Simply create rich Web 2.0 interfaces Application “is” the server Clean, short-lived runtime
  7. Speed WebSphere sMash is easy for developers to access, learn, and use <ul><li>Dynamic Scripting </li></ul><ul><ul><li>PHP </li></ul></ul><ul><ul><li>Groovy (Java TM Language Syntax) </li></ul></ul><ul><li>Effortless creation of RESTful Services </li></ul><ul><li>Simple event-based execution environment </li></ul><ul><li>State externalized into a shared memory space (Global Context) </li></ul><ul><li>Repository of pre-built templates, services, libraries, and connectors </li></ul>
  8. Simplicity WebSphere sMash makes it simple to “mash-up” services and feeds <ul><li>Free browser-based and Eclipse-based tools provide a simple environment for constructing applications based on dynamic scripting languages. </li></ul><ul><li>Visual tooling makes it simple to create complex, rich, dynamic, data-centric Web 2.0 user interfaces based on Ajax. </li></ul><ul><li>sMash is a full stack runtime – JEE web container not required. </li></ul>
  9. Agility WebSphere sMash focuses on deploying applications, not servers <ul><li>Cost effective execution </li></ul><ul><ul><li>Memory and disk footprint minimal. </li></ul></ul><ul><ul><li>Many apps possible per box. </li></ul></ul><ul><li>Clean execution </li></ul><ul><ul><li>Applications are isolated and secured from each other </li></ul></ul><ul><ul><li>Periodic re-cycling of applications reduces failures </li></ul></ul>
  10. Dynamic Scripting <ul><li>WebSphere sMash is a dynamic scripting platform </li></ul><ul><li>Application Logic is created in one of two scripting languages </li></ul><ul><ul><li>PHP (for the 3 Million existing PHP programmers) </li></ul></ul><ul><ul><li>Groovy (for people that prefer Java TM ) </li></ul></ul><ul><li>Java is positioned as the “system” language </li></ul><ul><ul><li>Mostly used to implement system extensions and application libraries </li></ul></ul><ul><ul><li>Entire applications can be written in Java, if desired </li></ul></ul><ul><ul><ul><li>Requires more configuration </li></ul></ul></ul>
  11. Application-centric Runtime <ul><li>WebSphere sMash is an application-centric runtime </li></ul><ul><ul><li>You create an application and run it </li></ul></ul><ul><ul><li>You do not package an application and deploy it to a multi-application server </li></ul></ul><ul><ul><li>Each application runs in its own process (JVM) </li></ul></ul><ul><ul><li>Runtime is designed to be short lived </li></ul></ul><ul><li>WebSphere sMash is a full stack runtime </li></ul><ul><ul><li>Everything needed to run the application is provided </li></ul></ul><ul><ul><ul><li>Including the HTTP stack </li></ul></ul></ul><ul><ul><li>No external proxy or web server is required </li></ul></ul><ul><ul><ul><li>Except for clustering and multi-app routing </li></ul></ul></ul>
  12. Modular Architecture <ul><li>WebSphere sMash applications are based on a very small core </li></ul><ul><li>Additional features provided in downloadable modules </li></ul><ul><ul><li>Applications declare dependencies using Apache Ivy </li></ul></ul><ul><ul><li>A package management system manages your dependencies, including facilities to: </li></ul></ul><ul><ul><ul><li>share dependencies on a machine </li></ul></ul></ul><ul><ul><ul><li>load missing dependencies from the network on demand </li></ul></ul></ul><ul><ul><ul><li>manage updates to dependencies </li></ul></ul></ul>
  13. Available Modules <ul><li>There are approximately 65 modules available currently </li></ul><ul><li>Modules provide function in many categories </li></ul><ul><ul><li>Data Formats (JSON, ATOM, RSS, XML) </li></ul></ul><ul><ul><li>Data Access </li></ul></ul><ul><ul><li>Resource Modeling </li></ul></ul><ul><ul><li>Security / Content Filtering </li></ul></ul><ul><ul><li>Activity Flows </li></ul></ul><ul><ul><li>Services </li></ul></ul><ul><ul><ul><li>Amazon ECS, Flickr, Weather, etc </li></ul></ul></ul><ul><ul><li>Utilities (such as HTML parsing) </li></ul></ul><ul><ul><li>Management Tools </li></ul></ul><ul><ul><li>Development Tooling </li></ul></ul><ul><ul><li>Reliable Transport Engine for Messaging Interactions </li></ul></ul>
  14. Agenda <ul><li>Overview of WebSphere sMash </li></ul><ul><li>Simple sMash demonstration </li></ul><ul><li>PHP in sMash </li></ul><ul><li>PHP sMash demonstration </li></ul><ul><li>Summary and Questions </li></ul>
  15. Agenda <ul><li>Overview of WebSphere sMash </li></ul><ul><li>Simple sMash demonstration </li></ul><ul><li>PHP in sMash </li></ul><ul><li>PHP sMash demonstration </li></ul><ul><li>Summary and Questions </li></ul>
  16. WebSphere sMash PHP Support <ul><li>PHP runtime built in Java TM . </li></ul><ul><li>Compile PHP into Java bytecodes and run on a JVM. </li></ul><ul><li>Powerful blending of PHP and Java code. </li></ul><ul><ul><li>Java and PHP code run in the same process </li></ul></ul><ul><ul><ul><li>No need for Inter-process communication. </li></ul></ul></ul><ul><ul><li>Efficient calls between PHP, Java and Groovy </li></ul></ul><ul><ul><li>Pass data between PHP, Java and Groovy without copying </li></ul></ul><ul><ul><ul><li>Avoids serialising and passing data between processes. </li></ul></ul></ul><ul><ul><li>Import Java classes as PHP Classes </li></ul></ul><ul><ul><ul><li>Easy access to the many Java libraries from PHP code. </li></ul></ul></ul>
  17. PHP in WebSphere sMash Java Virtual Machine <ul><li>Runs PHP 5 scripts </li></ul><ul><li>Requires Java 5 SE or later. </li></ul><ul><li>Extensibility via XAPI </li></ul><ul><ul><li>XAPI-C for C extensions from php.net </li></ul></ul><ul><ul><li>XAPI-J for Java extensions, native libraries invoked over JNI and Project Zero interface </li></ul></ul><ul><ul><li>Extension language choice opaque to PHP script </li></ul></ul><ul><li>Java TM Bridge </li></ul><ul><li>Debug using via DBGp protocol using Eclipse with PDT </li></ul>P8 Runtime Interpreter/Compiler PHP runtime Java Extensions C Extensions XAPI-J XAPI-C PDT2 Java- Bridge JAR JAR JAR JAR Groovy runtime WebSphere sMash HTTP server Zero Programming Model DBGp Debug
  18. Benefits of PHP in sMash. <ul><li>Develop quickly using the best tools for the job. </li></ul><ul><ul><li>PHP code such as smarty, drupal, phpBB, </li></ul></ul><ul><ul><li>Java code such as Apache Lucene, POI and Eclipse BIRT </li></ul></ul><ul><li>Start simple using sMash tooling such as ZRM </li></ul><ul><ul><li>Customise and extend using PHP scripts and snippets </li></ul></ul><ul><li>Build on a solid base. </li></ul><ul><ul><li>PHP built on the Java VM at the heart of IBM’s enterprise software stack. </li></ul></ul><ul><ul><ul><li>Vast investment in JIT, Garbage Collector, RAS and tools. </li></ul></ul></ul><ul><li>Enable agile teams to use Java and PHP skills. </li></ul><ul><ul><li>Allow teams to use their full range of skills. </li></ul></ul><ul><ul><li>Integrate Java and PHP code seamlessly using the Java Bridge </li></ul></ul>
  19. PHP – Java Bridge – Basic use <?php java_import( &quot;java.util.Date&quot; ); $date = new Date( 81 , 9 , 12 ); echo $date . PHP_EOL; // prints: Sun Oct 11 00:00:00 BST 1981 java_import( &quot;java.util.HashMap&quot; ); $map = new HashMap(); $map ->put( &quot;stuff&quot; , array ( 1 , 2 , 3 , 4 , 5 )); var_dump( $map ->get( &quot;stuff&quot; )); // prints: array(5) { ... Access Java methods and fields from PHP <?php java_import( &quot;java.lang.System&quot; ); echo System::currentTimeMillis(); try { System::getProperty( FALSE ); } catch (JavaException $exception ) { echo $exception ->getMessage(); } Static methods and fields are accessible too Types are automatically converted at boundary of PHP runtime Java exceptions can be caught and handled in PHP
  20. Java Bridge – Extending Java in PHP <?php java_import( &quot;java.io.File&quot; ); class SubFile extends File { function SuperFile( $path ) { parent ::__construct( $path ); } function isThisCool() { return TRUE ; // Way cool } } $file = new Sub File( &quot;/&quot; ); var_dump( $file ->isDirectory()); var_dump( $file ->isThisCool()); PHP classes can extend Java classes
  21. PHP- Java Bridge – Iterators and Overloads Signatures provide explicit control for overloaded methods <?php java_import( &quot;java.util.ArrayList&quot; ); $list = new ArrayList(); $list ->add( &quot;Hello World!&quot; ); $list ->add( FALSE ); $list ->add( 1234567890 ); foreach ( $list as $key => $value ) { echo &quot; $key $value &quot; ; } Java iteration is bridged into PHP <?php java_import( &quot;java.lang.String&quot; ); $signature = new JavaSignature(JAVA_INT); var_dump(String::valueOf( $signature , 1234567890 ));
  22. Java Bridge – More features… <?php java_import( &quot;java.math.BigDecimal&quot; , NULL, FALSE , &quot;My_BigDecimal&quot; ); $value = new My_BigDecimal( &quot;1.18E+10&quot; ); echo $value ; Import a Java class under a different name to avoid clashes <?php java_import( &quot;java.lang.Comparable&quot; ); echo (ReflectionClass::export( &quot;Comparable&quot; )); PHP reflection works on Java classes <?php java_import( &quot;java.io.File&quot; ); $file = new File( &quot;/home/robinf&quot; ); var_dump( $file ->Parent); //equivalent to: var_dump( $file ->getParent()); Java bean support provides field access for get/set method calls
  23. Agenda <ul><li>Overview of WebSphere sMash </li></ul><ul><li>Simple sMash demonstration </li></ul><ul><li>PHP in sMash </li></ul><ul><li>PHP sMash demonstration </li></ul><ul><li>Summary and Questions </li></ul>
  24. Agenda <ul><li>Overview of WebSphere sMash </li></ul><ul><li>Simple sMash demonstration </li></ul><ul><li>PHP in sMash </li></ul><ul><li>PHP sMash demonstration </li></ul><ul><li>Summary and Questions </li></ul>
  25. Some PHP Applications that run on sMash Forums CRM wiki Desktop Virtualisation Ajax Debugging Content Management Blogging FirePHP
  26. Features we didn’t cover <ul><li>Client Programming with the Dojo Framework </li></ul><ul><li>Assemble Tooling </li></ul><ul><li>Data APIs </li></ul><ul><li>Security </li></ul><ul><li>Eclipse-based tooling </li></ul><ul><li>REST to SOAP adapter </li></ul><ul><li>Reliable Messaging </li></ul><ul><li>Error Handling </li></ul><ul><li>Logging, Tracing, Debugging </li></ul><ul><li>… </li></ul>
  27. Project Zero – projectzero.org <ul><li>Download sMash for free </li></ul><ul><li>View “Getting Started” guides </li></ul><ul><li>Watch videos of sMash in action </li></ul><ul><li>Access our source, bug tracker, developer discussions… </li></ul><ul><li>Chat with the community on the forum </li></ul>Visit http://projectzero.org Project Zero is the development and incubation community around WebSphere sMash  Come to our stand for more demos!
  28. Legal Notices <ul><li>Java and all Java-based trademarks and logos are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. </li></ul><ul><li>Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. </li></ul><ul><li>Intel and Pentium are trademarks or registered trademark of Intel Corporation or its subsidiaries in the United States and other countries. </li></ul><ul><li>UNIX is a registered trademark of The Open Group in the United States and other countries. </li></ul><ul><li>Linux is a trademark of Linus Torvalds in the United States, other countries, or both. </li></ul><ul><li>Other company, product, or service names may be trademarks or service marks of others. </li></ul>

×