We added PHP support a long time ago. At least 9 years ago for Xojo (called REALbasic at that time) and later for FileMaker in the year 2012 with version 2.9, about 5 years ago. The code is mostly identical for both and even allows to call back to the host application. In Xojo you can call an event in your Xojo code. In FileMaker you can trigger scripts, use evaluate and SQL to query your database. It works quite well for a few customers.
Currently we use PHP 5.6.12 or similar versions. The reason is that the plugin is compiled against a specific version. We tie into data structures where variables should not move. So as long as a version has internally the same offsets for the variables we use, it will work with newer and older versions. We do provide downloads of the PHP libraries we use for testing, so you can get exactly the same versions: Download our PHP library.
Recently we added a download archive called php4FileMaker provided by Philipp Puls from 72solutions GmbH in Austria. This is a newer version 5.6.24, which seems to be compatible for the data structures, so it works fine with current plugin. It includes a lot of extensions for both Mac and Windows.
Some extensions to PHP may be needed for your solution. The older library from us for Mac includes the following extensions: date, ereg, libxml, pcre, sqlite3, bcmath, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, SPL, json, mbstring, session, PDO, pdo_sqlite, standard, posix, Reflection, Phar, SimpleXML, soap, sockets, exif, tokenizer, xml, xmlreader and xmlwriter. The newer one adds gd, iconv, mcrypt, openssl and zip, but skips bcmath and sockets.
The Windows versions have more extensions including various databases. But as extensions are not built-in the library itself, you may need a php.ini file to initialize PHP and point to the extensions DLLs. We recommended to set the PHPRC environment variable to point to the folder with the php.ini file and additional DLLs, so they can be found.
You may ask why we don’t use PHP 7. Well, first every new PHP version is a lot of work as we need to build that version to get the configured header files for all platforms to build the plugin. And we need to patch the headers to work with a dynamically linked PHP library instead of static linking, which needs a lot of changes. Last week I tried it and got after several hours a Mac plugin with PHP 7 to compile. Just when loading the PHP 7 library it crashed in initialization, so well, we put that on hold. For the foreseeable future we stick with PHP version 5.6.
But there is a little improvement coming for next plugins. In the last ten years since the PHP functions are in development, I missed to find the globals in PHP for the last error information. Strange, but true. Now we got new properties LastErrorMessage, LastErrorLine and LastErrorFile to PHPMBS class. And for FileMaker the functions PHP.Run and PHP.Execute to return the proper error message, e.g. “[MBS] syntax error, unexpected 'd' (T_STRING) in Embedded code:7". This includes line number and for external PHP files their name. We just pass though whatever PHP provides as error message.
For your projects, the recommendation is to do the things you could do with PHP natively without PHP. MBS Plugins offer CURL, XML, JSON, Encryption, Compression and much more, so most of the features you may want to do in PHP can be done without it.
If you find PHP code on the Internet, don’t expect to run inside your solution. The snippets normally expect
- a newer PHP version. PHP7 has a few new syntax features.
- some modules or extensions need to be present and our extensions list is usually incomplete.
- some settings in PHP.ini to be configured.
- the folder structure of a web server.
- the environment variables provided by the web server.
If you have trouble with some SSL socket connections from PHP 5.6, you may want to use a transparent proxy to convert between HTTP and HTTPs.
But if you really need it, you will probably get the PHP code modified to run. Have fun and enjoy the plugin!
Newer plugins will be uploaded next week or if you like to test them earlier, do not hesitate to contact us.