What if you could run PHP code directly inside ColdFusion?

Posted by James Harvey at 8:42 AM on Nov 12, 2008
0 comments - Posted In: Cold Fusion | PHP

Share this: del.icio.us digg StumbleUpon Facebook Technorati Fav Mixx Spurl newsvine Furl reddit FARK Yahoo! My Web Wists Simpy BlinkList BlogMarks smarking Ma.gnolia MSN Live Google Bookmarks Segnalo diigo excites Netvouz

I found this blog post back in early 2008 that states you can run PHP (and Ruby) on Coldfusion 8. I thought this was pretty damed cool, especially considering I develop with both. So here's the Blog entry:

What if you could run PHP code directly inside ColdFusion?

<cfset who = "Sean" />
<cf_php>
<?php
echo "Hello ".$_COLDFUSION["who"]."<br />";
$_COLDFUSION["greeting"] = "wibble";
?>
</cf_php>
<cfoutput>greeting = #greeting#</cfoutput>

This outputs Hello Sean and greeting = wibble. Yes, you can pass ColdFusion variables into PHP and set variables in PHP that you can access back in ColdFusion land. [Note: Unlike the first version I posted, the new version takes no attributes but instead makes available the entire variables scope from the calling page - and now uses $_COLDFUSION which is more in keeping with PHP.]

How is this possible? Well, ColdFusion 8 uses Java 6 which provides access to the javax.script package and all the J-language implementations available. Quercus is a Java implementation of PHP and it is implemented as a script engine.

Sun has provided a number of JSR-223 ScriptEngine and ScriptEngineFactory implementations and there are Java implementations of a number of languages.

Combine that with a simple custom tag and the code you see above becomes a trivial extension for ColdFusion 8!

Installation instructions are given inside each script directory's example.cfm page. The project now has Ruby support.

The source code is available on Google Code - along with my other Open Source projects and I'm setting up a central location on RIAForge as well (as soon as Ray approves my project request).

You can also download the code here, as well as in my Downloads Section.

The Original Post is Here.

 





Comments on What if you could run PHP code directly inside ColdFusion?

0 responses to “What if you could run PHP code directly inside ColdFusion? ”

Make a comment on What if you could run PHP code directly inside ColdFusion?

:
:
:
:






Share this: del.icio.us digg StumbleUpon Facebook Technorati Fav Mixx Spurl newsvine Furl reddit FARK Yahoo! My Web Wists Simpy BlinkList BlogMarks smarking Ma.gnolia MSN Live Google Bookmarks Segnalo diigo excites Netvouz