Orchard Hungary is an archive

This site is now an archive. We'll keep it so the content is accessible, but we won't update it anymore. However, we frequently publish Orchard-related news on our other site Orchard Dojo, so be sure to check that out instead. And if you're interested in news about our Orchard development company, Lombiq, check out our website.

PHP scripting for Orchard

Tags: Orchard, scripting, PHP, modules, release, Phalanger, Rules, Orchard HUN

Over the weekend Benedek and Zoltán (me) have worked hard on something very new: adding PHP scripting support for Orchard!

Thanks to the Phalanger project it's possible to compile PHP scripts to .NET assemblies as well as run PHP scripts dynamically by defining the script source at runtime. This comes with full interoperability between the two platforms: PHP scripts can use .NET types and objects can be passed between PHP and .NET. So you can use PHP to script a .NET application like Orchard. Did I mention how awesome this is?

With our two new modules, Orchard Scripting Extensions and Orchard Scripting Extensions: PHP we deliver a set of services to enable running scripts using Orchard services, hooked into Orchard's events. Features are:

  • Extensible scripting services: basically with implementing a very simple interface (IScriptingRuntime) you can write your own scripting runtime and thus extend everything that we've already written (see e.g the action below).
  • Scripting actions: with the new Script Execution action scripts can be run when an event in the Rules engine is raised. This way scripts can be run e.g. when a content item is published or even scheduled.
  • Dashboard testbed: under the Scripting admin menu item you can try out your scripts by running them immediately. The testbed has a decent syntax-highlighted editor thanks to the awesome ACE editor.
  • PHP view engine: with the PHP view engine you can have .php views; that means, you can have themes written in PHP!

What is this good for? Why do I want to be able to run PHP scripts in Orchard?

  • Learning PHP is easy: everybody is a PHP developer, even if some people don't know it yet. This means through PHP scripting we can essentially enable limited Orchard development for people who don't want to or can't learn C#, the usage of Visual Studio or anything corresponding with .NET Orchard development.
  • There are plenty of people out there who already know they're PHP developers. Is there a better way to ask them to try Orchard than telling them it has PHP as well?
  • Migrating a PHP-built CMS (and possibly steering the dev team towards .NET) can be less painful when parts of the project can be kept with small changes (like views) or existing know-how can be re-used.
  • Migrating a theme from a PHP-based CMS (like it was done from Wordpress at least once) can be less painful.

Oh, C# and VB scripting is also on its way.

Got excited? We hope so, please read the documentation of Orchard Scripting Extensions and Orchard Scripting Extensions: PHP on how you can employ scripting to enhance your Orchard site.

Happy PHP coding!

No Comments