8

I'm wondering if there are any abstraction frameworks for one of the PHP gui libraries. We have PHP-GTK, a PHP/Tk interface, and seemingly also PHP-QT. (Not tried any.)

I know that writing against the raw Gtk+ interface in Python is just bearable, and it therefore seems not very enticing for PHP. I assume it's the same for Qt, and Tk is pretty low-level too. So I'm looking for something that provides a nicer object structure atop any of the three. Primarily TreeViews are always a chore and php-gtk callbacks are weird in PHP, so I'd like a simplification for that. If it eases adding the GUI/View atop my business logic without much control code, that might already help.

And so since GUI apps are an area where MVC or MVP would actually make sense, I'd like to know if any library for that exists.

Still open for answers.
(There will probably be a second bounty round. It's an uncommon topic, so needs more research.)

mario
  • 144,265
  • 20
  • 237
  • 291
  • 3
    Haven't seen MVC libs for GUI PHP apps - probably mainly since they are a rather rare breed - but interesting question nonetheless. – Jani Hartikainen Jan 02 '11 at 01:18
  • I'd love to see something like this, ideally with support for JS-based RIA frameworks like ExtJS and Dojo or even XUL, but that's probably just a pipedream. – Gordon Jan 05 '11 at 13:03
  • This is interesting, and a relatively new direction for PHP, one I'd like to see it move in, to better compete with .Net and Java. I'm formally offering to contribute to any open source projects along these lines. Alert me if you start one as the result of this question. – DampeS8N Jan 10 '11 at 13:45

5 Answers5

2

[Not an answer. Just wanted to remove this from the question, as it's only related, not a solution.]

There is the PHP interface preprocessor. However it is very simple and low-level. It provides an output interface for Gtk, as well as ncurses, but also PDF or XHTML serialization. Which is interesting, as it's close to real MVC constructs in allowing to exchange the View for different backends without adapting the Controller even. But then it only provides the basic widgets, and not a whole lot of simplifications. Thus I only consider it related to my original question. So, a side note.

mario
  • 144,265
  • 20
  • 237
  • 291
1

Have you tried WinBinder? Not exactly MVC related, but a very nice extension to create gui based programs in PHP.

Samnan
  • 653
  • 1
  • 5
  • 13
  • Not considered since it's Windows-only, no use to me. The callback API is a bit more clumsy than in php-gtk. But it's related, so let's leave this tip here. Someone else might find it more useful than the other GUI toolkits. – mario Jan 03 '11 at 15:42
1

Now there are a few options that work on newer versions of php. Some of these do not provide you with MVC out of the box, but you can use them to make GUI application in php.

There is the very easy to use php-gui. It does not require any special php extentions, you can just install it with composer like any other php library or framework you depend on. It is geared toward simple, standard user interfaces.

If you need to make something very custom and graphically advanced, and are willing to use an API that was designed to make games in C (or if you want to make a game in php), you could use OpenGL via SDL via FFI via ffi-sdl. It currently (as of 6/1/2020) requires php 7.4 or greater as it uses the recently added ffi feature of php. Even though this relies on the ffi extension, php-ffi is still easy to add to your project. It is still sort of extensionless (like php-gui) because there are no extensions tailor made just for this for it to work. Unlike some other extensions, there is not much chance ffi will not be maintained since it is a feature of php itself. Most people will just need to add ff-sdl to their project using composer, and possibly enable ffi in their php.ini.

I just learned you could also use PeachPie. It allows you to compile and run php code for/on .NET, so you would gain access to .NET GUI libraries, including MVC ones.

still_dreaming_1
  • 8,661
  • 6
  • 39
  • 56
0

I really doubt that you'll find anything like that ready to use OotB. PHP GUI programming has totally failed few years ago.

What you can do however, is use some kind of bridge to interface decent MVC from another language. Which PHP you have following choices:

vartec
  • 131,205
  • 36
  • 218
  • 244
  • Swig/Boost were probably the basis for the Gtk, Tk and Qt bindings. The Java bridge is somewhat fancy (and complex), but an interesting avenue for further research. And then Quercus or ProjectZero might also make sense. Ultimatively I would prefer a Python IPC bridge though.. – mario Jan 10 '11 at 19:43
  • In case you'd switch to Python, you really hav a *lot* more choice. Including very popular wxWidgets. – vartec Jan 11 '11 at 09:06
  • As for Quercus and ProjectZero, they are nor really 100% compatible with PHP from Zend. – vartec Jan 11 '11 at 09:07
0

http://phpketchup.isgreat.org/ PHPKetchup is a new project in planning stage. There isn't any code available for now (also seems intended commercial, not open source). It was announced as framework atop PHP-GTK. There is a conception document which explicitly lists the goal as designing a MVC framework.

However it seems like they take inspiration from CodeIgniter and mostly the common PHP framework structure. The focus seems not to lie on integrating PHP-GTK with the application logic, but mostly to provide a database interface as model and a thin Gtk interface for the View.

MVC Architecture:
We will design and implement Model-View-Controller (MVC) architecture for the PHP-GTK framework. SQLite will be used for Model. PHP-GTK functions and Glade files will be integrated in View after removal of HTML, CSS and Javascript. Controller will be modified accordingly to work with the newly created View.

So it might just be MVC in name and organization, but one of the diagrams mentions "PHP-GTK functions addition" and there are further hints of object-structured Gtk helpers.

mario
  • 144,265
  • 20
  • 237
  • 291