php-ext-hello という拡張モジュールがローカルにあることを前提とします。
PHP 拡張モジュールのフォルダーに composer.json を設置します。
composer.json
{
"name": "masakielastic/php-ext-hello",
"description": "Hello World extension",
"version": "0.1",
"type": "php-ext",
"license": "BSD-3-Clause",
"require": {
"php": ">=8.1"
},
"php-ext": {
"extension-name": "hello"
}
}リポジトリにはタグが設定されていることを前提とします。
git tag 0.1ローカルのリポジトリを登録します。
pie repository:add path /home/masakielastic/php-ext-hello登録されたかどうかを確認します。
pie repository:listビルドしてみます。
pie build masakielastic/php-ext-hello結果は次のようになります。
🥧 PHP Installer for Extensions (PIE) 1.3.8, from The PHP Foundation
You are running PHP 8.5.3
Target PHP installation: 8.5.3 nts, on Linux/OSX/etc x86_64 (from /usr/bin/php8.5)
Found package: masakielastic/php-ext-hello:0.1 which provides ext-hello
Extracted masakielastic/php-ext-hello:0.1 source to: /home/masakielastic/.config/pie/php8.5_6196662ea494e76a7aab6ead04c3b45b/vendor/masakielastic/php-ext-hello
phpize complete.
Configure complete with options: --with-php-config=/usr/bin/php-config
Build complete: /home/masakielastic/.config/pie/php8.5_6196662ea494e76a7aab6ead04c3b45b/vendor/masakielastic/php-ext-hello/modules/hello.soインストールしてみます。
masakielastic@penguin:~/test$ pie install masakielastic/php-ext-hello
結果は次のとおりです。
🥧 PHP Installer for Extensions (PIE) 1.3.8, from The PHP Foundation
This command may need elevated privileges, and may prompt you for your password.
You are running PHP 8.5.3
Target PHP installation: 8.5.3 nts, on Linux/OSX/etc x86_64 (from /usr/bin/php8.5)
Found package: masakielastic/php-ext-hello:0.1 which provides ext-hello
Extracted masakielastic/php-ext-hello:0.1 source to: /home/masakielastic/.config/pie/php8.5_6196662ea494e76a7aab6ead04c3b45b/vendor/masakielastic/php-ext-hello
Build files cleaned up.
phpize complete.
Configure complete with options: --with-php-config=/usr/bin/php-config
Build complete: /home/masakielastic/.config/pie/php8.5_6196662ea494e76a7aab6ead04c3b45b/vendor/masakielastic/php-ext-hello/modules/hello.so
Cannot write to /usr/lib/php/20250925, so using sudo to elevate privileges.
Install complete: /usr/lib/php/20250925/hello.so
✅ Extension is enabled and loaded in /usr/bin/php8.5
PHP がモジュールをロードしているか確認します。
masakielastic@penguin:~/test$ pie install masakielastic/php-ext-hello
🥧 PHP Installer for Extensions (PIE) 1.3.8, from The PHP Foundation
This command may need elevated privileges, and may prompt you for your password.
You are running PHP 8.5.3
Target PHP installation: 8.5.3 nts, on Linux/OSX/etc x86_64 (from /usr/bin/php8.5)
Found package: masakielastic/php-ext-hello:0.1 which provides ext-hello
Extracted masakielastic/php-ext-hello:0.1 source to: /home/masakielastic/.config/pie/php8.5_6196662ea494e76a7aab6ead04c3b45b/vendor/masakielastic/php-ext-hello
Build files cleaned up.
phpize complete.
Configure complete with options: --with-php-config=/usr/bin/php-config
Build complete: /home/masakielastic/.config/pie/php8.5_6196662ea494e76a7aab6ead04c3b45b/vendor/masakielastic/php-ext-hello/modules/hello.so
Cannot write to /usr/lib/php/20250925, so using sudo to elevate privileges.
Install complete: /usr/lib/php/20250925/hello.so
✅ Extension is enabled and loaded in /usr/bin/php8.5
PHP CLI ツールで hello モジュールがロードされているかチェックします。
php -m | grep hello
hello
Github リポジトリを登録して利用するには次のコマンドを実行します。
pie repository:add vcs https://github.com/masakielastic/php-ext-hello
登録されたかどうか確認します。
pie repository:list