Java and COM

While there are a large number of extensions available for PHP, a particular few stand out because they are technology extensions as opposed to just library extensions. That is, they allow you to make use of a particular technology from inside PHP, as if you were using it directly.

The most interesting of these extensions are the Java and COM extensions, because they give you a very simple interface into these powerful technologies, allowing you to make use of their functionality without straying too far away from PHP. Java, particularly, is seen as being an interesting match for PHP because they are both cross-platform, and both Internet-based.

Microsoft's Component Object Model (COM) system is available for Windows only, so Unix users will need to get by with just Java. If you are using Windows, and do not mind restricting your scripts to Windows only, then you can have lots of fun exploring how COM and PHP can fit together.

This chapter is devoted to exploring how you can mix in these two popular buzzwords with PHP - not just on a theoretical, "look what I can do" level, but also for practical benefit in your scripts. PHP is a great language, but you should never let that stop you from taking bits and pieces from other technologies wherever it will improve your scripts. Having said that, I like trying things out - even crazy things - for kicks now and then, and I hope that's been reflected here too.

Topics covered in this chapter are:

  • How to use COM

  • Finding out what components you have installed

  • Advanced COM - controlling Internet Explorer, and even writing VBScript

  • Distributed COM: COM over a network

  • Running Java in your scripts

  • Creating interfaces with Swing

Chapter contents

  1. 14.1. Getting started with COM
    1. 14.1.1. Instantiating an object
    2. 14.1.2. Basic COM
    3. 14.1.3. Advanced COM
    4. 14.1.4. The possibilities of COM
    5. 14.1.5. DCOM
    6. 14.1.6. Microsoft .NET
  2. 14.2. Bringing Java into the mix
    1. 14.2.1. Basic Java use
    2. 14.2.2. The drawbacks of basic Java use
    3. 14.2.3. Your own classes
    4. 14.2.4. Using Swing
    5. 14.2.5. The future of PHP and Java
  3. 14.3. Summary
  4. 14.4. Exercises
  5. 14.5. Further reading
  6. 14.6. Next chapter

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Getting started with COM >>

Previous chapter: Next chapter

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.