{"id":20536227,"url":"https://github.com/easysoft/phpmicro","last_synced_at":"2025-04-06T04:15:34.780Z","repository":{"id":39116354,"uuid":"318129074","full_name":"easysoft/phpmicro","owner":"easysoft","description":"micro sfx SAPI for php","archived":false,"fork":false,"pushed_at":"2024-09-09T02:34:41.000Z","size":261,"stargazers_count":282,"open_issues_count":7,"forks_count":32,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T03:05:45.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/easysoft.png","metadata":{"files":{"readme":"Readme.EN.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":"2020-12-03T08:43:39.000Z","updated_at":"2025-03-27T02:15:09.000Z","dependencies_parsed_at":"2024-09-09T03:29:34.236Z","dependency_job_id":"3e84491c-4c8f-4b9e-b036-360b5191b7c4","html_url":"https://github.com/easysoft/phpmicro","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easysoft%2Fphpmicro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easysoft%2Fphpmicro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easysoft%2Fphpmicro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easysoft%2Fphpmicro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/easysoft","download_url":"https://codeload.github.com/easysoft/phpmicro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430963,"owners_count":20937875,"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":[],"created_at":"2024-11-16T00:35:48.818Z","updated_at":"2025-04-06T04:15:34.626Z","avatar_url":"https://github.com/easysoft.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# micro self-executable SAPI for PHP\n\n[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-white)](Readme.md)\n![php](https://img.shields.io/badge/php-8.0--8.2-royalblue.svg)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![tests](https://github.com/dixyes/phpmicro/actions/workflows/tests.yml/badge.svg)](https://github.com/dixyes/phpmicro/actions/workflows/tests.yml)\n\nmicro self-executable SAPI makes PHP self-executable.\n\nJust concatenate micro.sfx and a random PHP source file or PHAR into a single file to use it.\n\n## Compatibility\n\nCurrently, it only supports PHP8+ on Windows, Linux, and macOS (and maybe some BSDs).\n\n## Fetch and Usage\n\nA micro `micro.sfx` binary containing the minimal extensions set is built automatically in [Github Actions](actions). If you need more extensions, build your own micro or use [crazywhalecc/static-php-cli](https://github.com/crazywhalecc/static-php-cli) (swoole/swow/libevent) or grab one in [lwmbs actions](https://github.com/dixyes/lwmbs/actions)(swow)\n\nTo use it, simply concatenate the `micro.sfx` file and any PHP source.\n\nFor example: if the content of myawesomeapp.php is\n\n```php\n\u003c?php\necho \"hello, this is my awesome app.\" . PHP_EOL;\n```\n\nOn Linux/macOS:\n\nNote for macOS users: If you've downloaded micro.sfx and macOS does not let you execute it, try:\n\n```bash\nsudo xattr -d com.apple.quarantine /path/to/micro.sfx\n```\n\nthen\n\n```bash\ncat /path/to/micro.sfx myawesomeapp.php \u003e myawesomeapp\nchmod 0755 ./myawesomeapp\n./myawesomeapp\n# shows \"hello, this is my awesome app.\"\n```\n\nor Windows:\n\n```batch\nCOPY /b \\path\\to\\micro.sfx + myawesomeapp.php myawesomeapp.exe\nmyawesomeapp.exe\nREM shows \"hello, this is my awesome app.\"\n```\n\n## Build micro.sfx\n\n### Preparation\n\n1.Clone this repository into `sapi/micro` under the PHP source directory\n\n```bash\n# prepare PHP source\ngit clone --branch 'PHP-choose-a-release' https://github.com/php/php-src/ php-src\ncd php-src\n# at PHP source dir\ngit clone \u003curl for this repo\u003e sapi/micro\n```\n\n2.Apply patches\n\nPatches are placed in the \"patches\" directory. Choose patch(es) as you like, see [Readme.md](patches/Readme.md) in the patches dir for detail\n\nApply a patch:\n\n```bash\n# at PHP source dir\npatch -p1 \u003c sapi/micro/patches/\u003cname of patch\u003e\n```\n\n### UNIX-like Build\n\n0.Prepare the build environment according to [the official PHP documents](https://www.php.net/manual/en/install.unix.php).\n\n1.buildconf\n\n```bash\n# at PHP source dir\n./buildconf --force\n```\n\n2.configure\n\n```bash\n# at PHP source dir\n./configure \u003coptions\u003e\n```\n\nOptions for reference:\n\n`--disable-phpdbg --disable-cgi --disable-cli --disable-all --enable-micro --enable-phar --with-ffi --enable-zlib`\n\nOn Linux, libc compatibility can be a problem. To address this, micro provides two kinds of `configure` arguments:\n\n- `--enable-micro=yes`or`--enable-micro`: this will make PIE shared ELF micro sfx, this kind of binary cannot be invoked cross libc (i.e. you cannot run such a binary which was built on alpine with musl on any glibc-based CentOS), but the binary can do ffi and PHP `dl()` function.\n- `--enable-micro=all-static`: this will make full static ELF micro sfx, this kind of binary can even run barely on top of any linux kernel, but ffi/`dl()` is not supported.\n\n3.make\n\n```bash\n# at PHP source dir\nmake micro\n```\n\n(`make all`(aka. `make`) may work also, but it is recommended to only build the micro SAPI.)\n\nThe built file will be located at sapi/micro/micro.sfx.\n\n### Windows Build\n\n0.Prepare the build environment according to [the official PHP documents](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2), you may also try [my scripts](https://github.com/dixyes/php-dev-windows-tool)\n\n1.buildconf\n\n```batch\n# at PHP source dir\nbuildconf\n```\n\n2.configure\n\n```batch\n# at PHP source dir\nconfigure \u003coptions\u003e\n```\n\nOptions for reference:\n\n`--disable-all --disable-zts --enable-micro --enable-phar --with-ffi --enable-zlib`\n\n3.make\nDue to the PHP build system's inability to statically build PHP binaries on Windows, you cannot build micro with `nmake` command.\n\n```batch\n# at PHP source dir\nnmake micro\n```\n\nThat built file is at `\u003carch name like x64\u003e\\\\\u003cconfiguration like Release\u003e\\\\micro.sfx`.\n\n## Optimizations\n\nThe Hugepages optimization for Linux in the PHP build system results in a large sfx size. If you do not take advantage of Hugepages, use `disable_huge_page.patch` to reduce the sfx size.\n\nA static build under Linux requires libc. The most common libc, glibc, may be large, so musl is recommended instead. Manually installed musl or some distros provided musl will provide `musl-gcc` or `musl-clang` wrapper, use one of them before configure by specify CC/CXX environs, for example\n\n```bash\n# ./buildconf things...\nexport CC=musl-gcc\nexport CXX=musl-gcc\n# ./configure things\n# make things\n```\n\nWe aim to have all dependencies statically linked into sfx. However, some distro does not provide static versions of them. We may manually build them.\n\nlibffi for example (note that the ffi extension is not supported in `all-static` builds):\n\n```bash\n# fetch sources througe git\ngit clone https://github.com/libffi/libffi\ncd libffi\ngit checkout \u003cversion you like, v3.3 for example\u003e\nautoreconf -i\n# or download tarball\nwget \u003curl\u003e\ntar xf \u003ctar name\u003e\ncd \u003cextracted name\u003e\n# if we use musl\nexport CC=musl-gcc\nexport CXX=musl-gcc\n# build, install it\n./configure --prefix=/my/prefered/path \u0026\u0026\nmake -j`nproc` \u0026\u0026\nmake install\n```\n\nthen build micro as\n\n```bash\n# ./buildconf things...\n# export CC=musl-xxx things...\nexport PKG_CONFIG_PATH=/my/prefered/path/lib/pkgconfig\n# ./configure things\n# make things\n```\n\n## Some details\n\n### INI settings\n\nSee wiki：[INI-settings](https://github.com/easysoft/phpmicro/wiki/INI-settings)(TODO: en version)\n\n### PHP_BINARY constant\n\nIn micro, the `PHP_BINARY` constant is an empty string. You can modify it using an ini setting: `micro.php_binary=somestring`\n\n## OSS License\n\n```plain\nCopyright 2020 Longyan\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n## remind me to update the English readme and fix typos and strange or offensive expressions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasysoft%2Fphpmicro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasysoft%2Fphpmicro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasysoft%2Fphpmicro/lists"}