PHP on Java 
      
     
      
       Robin Fernandes   (ibm) 
       [email_address] 
       @rewbs 
   ...

      
       PHP ? 
      
     
      
       “ PHP isn't so much a language as a   virtual explosion  at the  keyword ...

      
       PHP ? 
      
     
      
       in_array( $needle ,  $haystack ); 
       strpos( $haystack ,  $needle );...

      
       PHP ! 
      
     
      
       
       
      
     
      
       
      
     
      
       
      
 ...

      
       PHP ! 
      
     
      
       
       
      
     
      
       
      
     
      
       Photo by ...

      
       PHP ! 
      
     
      
       
       
      
     
      
       
      
     
      
       
      
 ...

      
       Why  integrate PHP and Java?  
      
     
      
       
       
      
     
      
       <ul>
        ...

      
       Why  run PHP  on the  JVM ?  
      
     
      
       
       
      
     
      
       <ul>
        
...

      
       How  PHP  runs on the  JVM 
      
     
      <?php 
      echo  'hello' ; 
      
       
       
       ...

      
       How  PHP  runs on the  JVM 
      
     
      
       <ul>
        
         <li>P8: a PHP 5.2 runtime imp...

      
       Some  Code ! 
      
     
      <?php 
      java_import( &quot;java.util.HashMap&quot; ); 
      $map  = ...

      
       Some more  Code ! 
      
     
      <?php 
      java_import( &quot;java.io.File&quot; ); 
      
      c...

      
       Some more  Code ! 
      
     
      <?php 
      java_import( &quot;java.util.ArrayList&quot; ); 
      
...

      
       PHP on Java:  Challenges  
      
     
      
       <ul>
        
         <li>PHP has no language specif...

      
       PHP on Java:  Challenges  
      
     
      
       <ul>
        
         <li>Extension functions & symb...

      
       PHP apps  +  Java libraries 
      
     
      
       <ul>
        
         For example... 
         
  ...

      
       Java apps  +  PHP scripting 
      
     
      
       
       
      
     
      
       <ul>
        
 ...

      
       PHP in  WebSphere sMash 
      
     
      
       
       
      
     
      
       <ul>
        
     ...

      
       One more bit of   Code ! 
      
     
      
       
      
     
      
       
      
     
      class ...

      
       PHP in  Message Broker 
      
     
      
       
       
      
     
      
       
       
      
    ...

      
       PHP in  CICS 
      
     
      
       
       
      
     
      
       <ul>
        
         Build R...

      
       Learn  more & Try  it out: 
      
     
      
       
       
      
     
      
       Thanks! 
       ...
Upcoming SlideShare
Loading in...5
×

Php On Java (London Java Community Unconference)

1,224

Published on

PHP on Java: Why run PHP on the JVM? How does it works? Where is it being used?

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

  • Be the first to like this

No Downloads
Views
Total Views
1,224
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
28
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Php On Java (London Java Community Unconference)

  1. 1. PHP on Java Robin Fernandes (ibm) [email_address] @rewbs
  2. 2. PHP ? “ PHP isn't so much a language as a virtual explosion at the keyword and function factory .” - Jeff Atwood from “PHP sucks, but it doesn't matter”
  3. 3. PHP ? in_array( $needle , $haystack ); strpos( $haystack , $needle ); ... IteratorIterator RecursiveIterator RecursiveIteratorIterator ... strip _ tags() strip s lashes() SDO _ Model _ Property::get C ontaining T ype() ReflectionClass::isItera tea ble()
  4. 4. PHP ! tiobe.com
  5. 5. PHP ! Photo by Michelangelo van Dam ( DragonBe )
  6. 6. PHP !
  7. 7. Why integrate PHP and Java? <ul> <li>PHP Developers to grow from 3 to 5.5 million by 2013 <li>PHP Developers in Corporate IT to grow from 13% to 60% by 2013 </ul> “ Pay special attention to opportunities to use PHP in combination with Java development efforts” <ul> - Gartner </ul>
  8. 8. Why run PHP on the JVM ? <ul> <li>PHP is a powerful and pragmatic language with a strong user-base <li>The Java Virtual Machines is a cutting edge language runtime </ul> PHP + JVM = ♥
  9. 9. How PHP runs on the JVM <?php echo 'hello' ; System. out .println( &quot;hello&quot; );
  10. 10. How PHP runs on the JVM <ul> <li>P8: a PHP 5.2 runtime implemented in Java <li>Runs on any Java 5+ JDK </ul> <ul> Extensibility <ul> <li>XAPI-C for existing C extensions <li>XAPI-J for new Java extensions </ul> (extension language choice is opaque to scripts) <li>Debug via DBGp using Eclipse PDT </ul> P8 Runtime SAPI-J Parser Interpreter P8 Engine Java Extensions C Extensions Stack Resources Classes Objects Variables AST XAPI-J XAPI-C Native code Compiler .class opcodes Cache Persistent class cache Debug API (DBGp) Runtime
  11. 11. Some Code ! <?php 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) { ...
  12. 12. Some more Code ! <?php java_import( &quot;java.io.File&quot; ); class SubFile extends File { function isThisCool() { return TRUE ; // Way cool } } $file = new SubFile( &quot;/&quot; ); var_dump( $file ->isDirectory()); var_dump( $file ->isThisCool());
  13. 13. Some more Code ! <?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; ; }
  14. 14. PHP on Java: Challenges <ul> <li>PHP has no language specification! <ul> <li>-> Write tests & contribute them back to php.net </ul> <li>Keeping up-to-date with php.net <ul> <li>-> As above! </ul> <li>Strings: byte array vs java.lang.String <ul> <li>-> Use byte arrays, convert sparingly. </ul> <li>Class format limitations <ul> <li>-> Use both compilation and interpretation. </ul> </ul>
  15. 15. PHP on Java: Challenges <ul> <li>Extension functions & symbol tables </ul> ✔ ✔ ✘ ✘ function f() { $a = 1 ; return $a ; } echo f(); //1 function f( $name ) { $a = 1 ; $ $name = 2 ; return $a ; } echo f( 'a' ); //2 function f() { $a = 1 ; extract( array ( 'a' => 3 )); return $a ; } echo f(); //3 function f() { $a = 1 ; print_r( array ( 'a' => 3 )); return $a ; } echo f(); //3
  16. 16. PHP apps + Java libraries <ul> For example... <ul> <li>SugarCRM + Apache POI <li>Drupal + Eclipse BIRT <li>PhpBB + Apache Lucene </ul> </ul>
  17. 17. Java apps + PHP scripting <ul> For example... </ul>
  18. 18. PHP in WebSphere sMash <ul> Build Web apps quickly and easily in Java , Groovy and PHP . </ul> <ul> <li>Lightweight web app runtime <li>Browser-based development tooling <li>Try it now: http://bit.ly/ibmCloud </ul> JVM Web Server Application Code Language Runtimes
  19. 19. One more bit of Code ! class Dynamic { def storage = [:] def invokeMethod(String name, args) { println &quot;Hello!&quot; } def getProperty(String name) { storage[name] } def setProperty(String name, value) { storage[name] = value } } <?php groovy_import( &quot;dynamic.groovy&quot; ); $foo = new Dynamic(); $foo ->bar(); $foo ->guff = &quot;Hello World!&quot; ; echo $foo ->guff;
  20. 20. PHP in Message Broker <ul> <li>Message Broker “ connects anything to anything ” <li>Routes and transforms data along the way <li>Use graphical mapping, XSLT, ESQL, Java and now PHP ! <li>With PHP, use a SimpleXML-inspired syntax to easily manipulate XML message formats. </ul>
  21. 21. PHP in CICS <ul> Build RESTful services based on CICS assets using PHP </ul> Transaction Server CICS assets: RESTful API to CICS assets SupportPac CA1S ... DB2 COBOL Java
  22. 22. Learn more & Try it out: Thanks! [email_address] / @rewbs http://projectzero.org/php http://bit.ly/ibmCloud
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×