PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

GObject Introspection is coming to PHP

Note: This article was originally published at Planet PHP on 24 February 2011.
Planet PHP

In the next-generation Midgard Content Repository we decided to focus on GObject Introspection for providing bindings to various programming languages like Python and JavaScript. The advantages for automatically generated bindings are quite obvious when compared to the situation with older Midgard versions where we had to maintain them manually. Unfortunately PHP didn't have GObject Introspection support, but that is about to change. Alexey from the Midgard team writes:

These days, a lot of effort in GNOME community goes into GObject Introspection project. They idea is, that bindings developers spend too much time by manually tweaking bindings to every change in C libraries. That's what PHP-GTK team had to do, for example.

Here's quotation from project's web site:

The introspection project solves this by putting all of the metadata inside the GObject library itself, using annotations in the comments. This will lead to less duplicate work from binding authors, and a more reliable experience for binding consumers. Additionally, because the introspection build process will occur inside the GObject libraries themselves, a goal is to encourage GObject authors to consider shaping their APIs to be more binding friendly from the start, rather than as an afterthought.

So, aointrospectiona branch aims to provide bindings for GObject Introspection infrastructure. The main entry point is GIRepository\load_ns(aNamespace') function, which creates php-counterparts of all classes, functions, constants of corresponding GObject namespace dynamically. At least, it will do that one day. With your help

Once this work is complete we aim to have PHP as a properly supported GNOME and MidgardCR language. I know some people despise the language, but it has its uses and supporters, especially in the web space. There access to various GNOME libraries can bring lots of possibilities. Telepathy or Tracker on a server? With GObject for PHP you could also write GNOME3 desktop applications in the language.