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
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.
3.
4.
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.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19. PHP – Java Bridge – Basic use <?php java_import( "java.util.Date" ); $date = new Date( 81 , 9 , 12 ); echo $date . PHP_EOL; // prints: Sun Oct 11 00:00:00 BST 1981 java_import( "java.util.HashMap" ); $map = new HashMap(); $map ->put( "stuff" , array ( 1 , 2 , 3 , 4 , 5 )); var_dump( $map ->get( "stuff" )); // prints: array(5) { ... Access Java methods and fields from PHP <?php java_import( "java.lang.System" ); 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( "java.io.File" ); class SubFile extends File { function SuperFile( $path ) { parent ::__construct( $path ); } function isThisCool() { return TRUE ; // Way cool } } $file = new Sub File( "/" ); 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( "java.util.ArrayList" ); $list = new ArrayList(); $list ->add( "Hello World!" ); $list ->add( FALSE ); $list ->add( 1234567890 ); foreach ( $list as $key => $value ) { echo " $key $value " ; } Java iteration is bridged into PHP <?php java_import( "java.lang.String" ); $signature = new JavaSignature(JAVA_INT); var_dump(String::valueOf( $signature , 1234567890 ));
22. Java Bridge – More features… <?php java_import( "java.math.BigDecimal" , NULL, FALSE , "My_BigDecimal" ); $value = new My_BigDecimal( "1.18E+10" ); echo $value ; Import a Java class under a different name to avoid clashes <?php java_import( "java.lang.Comparable" ); echo (ReflectionClass::export( "Comparable" )); PHP reflection works on Java classes <?php java_import( "java.io.File" ); $file = new File( "/home/robinf" ); var_dump( $file ->Parent); //equivalent to: var_dump( $file ->getParent()); Java bean support provides field access for get/set method calls
23.
24.
25. Some PHP Applications that run on sMash Forums CRM wiki Desktop Virtualisation Ajax Debugging Content Management Blogging FirePHP