{"id":19535695,"url":"https://github.com/miyako/4d-topic-php","last_synced_at":"2026-04-15T20:04:34.502Z","repository":{"id":191404454,"uuid":"684305386","full_name":"miyako/4d-topic-php","owner":"miyako","description":"Setup PHP for 4D","archived":false,"fork":false,"pushed_at":"2024-02-09T03:54:11.000Z","size":29528,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T17:55:36.960Z","etag":null,"topics":["4d","php"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miyako.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-28T21:45:16.000Z","updated_at":"2023-08-29T16:03:39.000Z","dependencies_parsed_at":"2023-12-23T10:26:38.396Z","dependency_job_id":"177e6aba-21b3-4099-bf6d-7a2f5001eca8","html_url":"https://github.com/miyako/4d-topic-php","commit_stats":null,"previous_names":["miyako/4d-topic-php"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miyako%2F4d-topic-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miyako%2F4d-topic-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miyako%2F4d-topic-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miyako%2F4d-topic-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miyako","download_url":"https://codeload.github.com/miyako/4d-topic-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240788775,"owners_count":19857699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["4d","php"],"created_at":"2024-11-11T02:19:38.403Z","updated_at":"2026-04-15T20:04:29.478Z","avatar_url":"https://github.com/miyako.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"![version](https://img.shields.io/badge/version-20%2B-E23089)\n\n# 4d-topic-php\nSetup PHP for 4D\n\n## Build static PHP with minimal dependencies\n\nClone or download [php-src](https://github.com/php/php-src).\n\nBy default, `re2c` is missing and `bison` is too old. \n\n```\nbrew install re2c\nbrew install bison\necho 'export PATH=\"/opt/homebrew/opt/bison/bin:$PATH\"' \u003e\u003e ~/.zshrc\n```\n\nRestart Terminal.\n\n```\ncd {php-src-master}\nautoreconf\nexport LIBS=\"-lz\"\n/configure --enable-static --without-iconv --prefix={path-to-install-dir}\nmake\nmake install\n```\n\nThis will install static `php-cgi` with only the following system dependencies:\n \n```\n/usr/lib/libresolv.9.dylib\n/usr/lib/libnetwork.dylib\n/usr/lib/libSystem.B.dylib\n/usr/lib/libz.1.dylib\n/usr/lib/libsqlite3.dylib\n```\n\nFor comparision, the v20 `php-fcgi-4d` file looks like this:\n\n```\n/usr/lib/libresolv.9.dylib\n/usr/lib/libnetwork.dylib\n/usr/lib/libSystem.B.dylib\n```\n\nAccording to the [PHP modules support](https://doc.4d.com/4Dv20/4D/20/PHP-modules-support.300-6238471.en.html) documentation, `SQLite3` is enabled so the library must be statically linked. `Zip`, `Zlib`, `Iconv`, as well as XML-releated featured that depend on `Zlib` are all disabled.\n\nTo create universal binary, restart Terminal using Rosetta, `make distclean`, repeat, then `lipo -create`.\n\n## Build static PHP with embedded `libz` and `libsqlite3`\n\nDownload libraries, then `lipo -create`:\n\n```\nbrew fetch --bottle-tag=arm64_big_sur sqlite\nbrew fetch --bottle-tag=x86_64_big_sur sqlite\nbrew fetch --bottle-tag=arm64_big_sur zlib\nbrew fetch --bottle-tag=x86_64_big_sur zlib\n```\n\nIndicate static library location:\n\n```\nexport LDFLAGS=\"-L{path-to-static-library-dir}\"\nexport LIBS=\"-lz -lsqlite3\"\n```\n\n**Error**: `sqlite3.c:446:6: error: call to undeclared function 'sqlite3_load_extension'`\n\nc.f. https://bugs.python.org/issue44997\n\nWe could edit */ext/sqlite3/sqlite3.stub.php* like so:\n\n```c\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    /** @tentative-return-type */\n#    public function loadExtension(string $name): bool {}\n#define SQLITE_OMIT_LOAD_EXTENSION 1\n#endif\n```\n…but this won't update the source files.\n\n**Solution**: Remove from *ext/sqlite3/sqlite3_arginfo.h*\n\n```c\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\nZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SQLite3_loadExtension, 0, 1, _IS_BOOL, 0)\n\tZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)\nZEND_END_ARG_INFO()\n#endif\n```\n\n…and add to *ext/sqlite3/sqlite3.c*\n\n```c\n#define SQLITE_OMIT_LOAD_EXTENSION 1\n```\n\nThis will install static `php-cgi` with the same 3 dependencies as `php-fcgi-4d`.\n\n## Build static PHP with embedded `libiconv`\n\nDownload libraries, then `lipo -create`:\n\n```\nbrew fetch --bottle-tag=arm64_big_sur libiconv\nbrew fetch --bottle-tag=x86_64_big_sur libiconv\n```\n\n**Error**: `configure: error: Please reinstall the iconv library.`\n\nIndicate static library location:\n\nWe could indicate static library location. Also add `-liconv` to `LDFLAGS`:\n\n```\nexport CFLAGS=\"-I{path-to-user-header-dir}\" \nexport LDFLAGS=\"-L{path-to-static-library-dir} -liconv\"\nexport LIBS=\"-lz  -lsqlite3 -liconv\"\n```\n\n…but this won't eliminate compiler errors.\n\n**Solution**: Remove `#undef` *ext/iconv/iconv.c*\n\n```c\n#ifdef HAVE_LIBICONV\n//#undef iconv\n#endif\n```\n\n## Does it actually work?\n\nRename the program as `php-fcgi-4d` and replace the one inside 4D.app.\n\nTest call:\n\n```4d\nvar $returnValue : Text\n\n$success:=PHP Execute(\"\"; \"phpversion\"; $returnValue)\n\nvar $response : Text\nARRAY TEXT($labels; 0)\nARRAY TEXT($values; 0)\n\nPHP GET FULL RESPONSE($response; $labels; $values)\n```\n\n**Result**: `$success` is `False`. Activity Monitor shows multiple instances of `php-fcgi-4d`. `X-4DPHP-Error-php-interpreter` contains the message:\n\n```\nPHP Fatal error:  Uncaught Error: Call to undefined function mb_convert_encoding() in _4D_Execute_PHP.php:131\n```\n\n**Solution**: Add `--enable-mbstring` to `configure`. \n\n## Build static PHP with embedded `libzip`\n\nThe homebrew distribution of [libzip](https://formulae.brew.sh/formula/libzip) is dynamic-only.\n\n**Solution**: Build from [source](https://github.com/nih-at/libzip). Uncheck `BUILD_SHARED_LIBS` in CMake.\n\n## Build static PHP with modules and extensions\n\n|Modules or Extension|Configure Option|4D v20|This Repository|\n|-|-|:-:|:-:|\n|[BCMath](https://www.php.net/manual/en/book.bc.php)|`--enable-bcmath`|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Calendar](https://www.php.net/manual/en/book.calendar.php)|`--enable-calendar`|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Character type checking](https://www.php.net/manual/en/book.ctype.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Client URL Library](https://www.php.net/manual/en/book.curl.php)|`--with-curl=DIR`|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Date and Time](https://www.php.net/manual/en/book.datetime.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Document Object Model](https://www.php.net/manual/en/book.dom.php)|(default)|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Exchangeable image information](https://www.php.net/manual/en/book.exif.php)|`--enable-exif`|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[File Information](https://www.php.net/manual/en/book.fileinfo.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Data Filtering](https://www.php.net/manual/en/book.filter.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[FTP](https://www.php.net/manual/en/book.ftp.php)|`--enable-ftp`|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[GNU Multiple Precision](https://www.php.net/manual/en/book.gmp.php)|`--with-gmp`|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[HASH Message Digest Framework](https://www.php.net/manual/en/book.hash.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[iconv](https://www.php.net/manual/en/book.iconv.php)|(default)|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Image Processing and GD](https://www.php.net/manual/en/book.image.php)|`--enable-gd --with-avif --with-webp --with-jpeg --enable-gd-jis-conv`|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[JavaScript Object Notation](https://www.php.net/manual/en/book.json.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[libxml](https://www.php.net/manual/en/book.libxml.php)|(default)|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Lightweight Directory Access Protocol](https://www.php.net/manual/en/book.ldap.php)|`--with-ldap`|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Multibyte String](https://www.php.net/manual/en/book.mbstring.php)|`--enable-mbstring`|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[OpenSSL](https://www.php.net/manual/en/book.openssl.php)|`--with-openssl`|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Regular Expressions (Perl-Compatible)](https://www.php.net/manual/en/book.pcre.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[PHP Data Objects](https://www.php.net/manual/en/book.pdo.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[SQLite Functions (PDO_SQLITE)](https://www.php.net/manual/en/ref.pdo-sqlite.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Phar](https://www.php.net/manual/en/book.phar.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[POSIX](https://www.php.net/manual/en/book.posix.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Random Number Generators and Functions Related to Randomness](https://www.php.net/manual/en/book.random.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Reflection](https://www.php.net/manual/en/book.reflection.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Sessions](https://www.php.net/manual/en/features.sessions.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[SimpleXML](https://www.php.net/manual/en/book.simplexml.php)|(default)|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Sockets](https://www.php.net/manual/en/book.sockets.php)|`--enable-sockets`|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[SQLite3](https://www.php.net/manual/en/book.sqlite3.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Standard PHP Library (SPL)](https://www.php.net/manual/en/book.spl.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Tidy](https://www.php.net/manual/en/book.tidy.php)|`--with-tidy=DIR`|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Tokenizer](https://www.php.net/manual/en/book.tokenizer.php)|(default)|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[XML Parser](https://www.php.net/manual/en/book.xml.php)|(default)|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[XMLReader](https://www.php.net/manual/en/book.xmlreader.php)|(default)|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[XMLWriter](https://www.php.net/manual/en/book.xmlwriter.php)|(default)|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Zip](https://www.php.net/manual/en/book.zip.php)|`--with-zip`|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n|[Zlib Compression](https://www.php.net/manual/en/book.zlib.php)|`--with-zlib`|*disabled*|\u003cul\u003e\u003cli\u003e- [x] \u003c/li\u003e\u003c/ul\u003e|\n\n### Configure Options\n\n```\n./configure\n --with-tidy=DIR\n --with-ldap=DIR\n --with-curl=DIR\n --with-openssl=DIR\n --with-zlib\n --with-gmp\n --with-zip\n --enable-static\n --enable-bcmath\n --enable-calendar\n --enable-exif\n --enable-ftp\n --enable-gd --with-avif --with-webp --with-jpeg --enable-gd-jis-conv\n --enable-sockets\n --enable-mbstring\n```\n\n### Static Libraries and Frameworks\n\n```\nexport LIBS=\"\n -lz\n -lsqlite3\n -liconv\n -lbz2\n -lzip\n -lzstd\n -lonig\n -llzma\n -lgd\n -lwebp -lavif -ltiff -lpng16 -lsharpyuv\n -ltidy\n -lgmp\n -lcrypto -lssl\n -lcurl -lnghttp2 -lidn2 -lssh2 -lldap -llber\n -lbrotlidec -lbrotlienc -lbrotlicommon\n -lsasl2\n -lunistring\n -lrtmp\n -framework GSS\n -framework SystemConfiguration\n -framework Cocoa\n -framework Security\n -framework LDAP\n -framework Kerberos\"\n```\n\n## Build static PHP with embedded `libcurl`\n\n**Error**: `configure: error: There is something wrong. Please check config.log for more information.`\n\n**Solution**: Add path to custom installations:\n\n```\n./configure\n --with-curl=DIR\n --with-openssl=DIR\n```\n\n**Error**: Undefined symbols: `libunistring` expects a non-plug version of `libiconv`. \n\n**Solution**: Compile and use a hybrid version that contains both names (`_iconv` and `_libiconv`).\n\n**Error**: Undefined symbols: `libbrotli` constants.\n\n**Solution**: Specify subdirectory paths to header files:\n\n```\nexport CFLAGS=\"\n -I{path-to-user-header-dir}\n -I{path-to-user-header-dir}/brotli\n -I{path-to-user-header-dir}/curl\"\n```\n\n## Build static PHP with embedded `libldap`\n\n**Error**: `configure: error: Cannot find ldap.h`\n\n**Solution**: Add path to custom installations:\n\n```\n./configure\n --with-ldap=DIR\n```\n\n## Build static PHP with [interactive shell](https://www.php.net/manual/en/features.commandline.interactive.php) support\n\n**Error**: `configure: error: Please reinstall readline - I cannot find readline.h`\n\n**Solution**: Add path to custom installations:\n\n```\n--with-readline=DIR\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiyako%2F4d-topic-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiyako%2F4d-topic-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiyako%2F4d-topic-php/lists"}