| name | description |
|---|---|
php-pecl-package |
Automated PHP PECL package creation workflow for building standard tgz packages from source code. Use when Claude needs to package PHP extensions for PECL distribution. Handles updating package.xml with version/date/changelog, validating file completeness, running pear package command, and verifying package integrity with configure/make. Requires pear command-line tool and a ChangeLog file. |
Automated workflow for creating PHP PECL-standard tgz packages from source code.
To package a PHP extension:
python3 scripts/package_pecl.py --version 1.0.0 --changelog ChangeLogThis will:
- Parse the ChangeLog file for release notes
- Update version numbers in source code files (.c, .h, .php)
- Update package.xml with version, date, and changelog
- Validate that all files listed in package.xml exist
- Run
pear packageto create the tgz - Extract and validate the package with
./configure && make
- pear command-line tool: Must be installed and available in PATH
- package.xml: Must exist in the source directory
- ChangeLog file: Contains release notes for the new version
- PHP development tools: phpize (for validation)
Ensure your extension directory contains:
package.xmlwith complete file list- Source files (.c, .h, config.m4)
ChangeLogfile with release notes
# Basic usage (current directory)
python3 scripts/package_pecl.py --version 1.0.0 --changelog ChangeLog
# Specify source directory
python3 scripts/package_pecl.py --version 2.1.3 --changelog RELEASE_NOTES.md --source /path/to/extension
# Skip validation (faster, less thorough)
python3 scripts/package_pecl.py --version 1.5.0 --changelog ChangeLog --no-validateThe script automatically updates version numbers in source code files before updating package.xml. It searches for common version patterns in:
-
C/C++ files (.c, .h):
#define EXTNAME_VERSION "1.0.0"const char *version = "1.0.0";static const char version[] = "1.0.0";
-
PHP files (.php):
const VERSION = '1.0.0';define('VERSION', '1.0.0');$version = "1.0.0";private const VERSION = '1.0.0';
If no version patterns are found, the script continues with a warning message.
The script will:
- ✅ Show parsed changelog content
- ✅ Update version numbers in source code files
- ✅ Update package.xml with new version and date
- ✅ Validate all files exist
- ✅ Build .tgz package
- ✅ Extract and test compilation (unless --no-validate)
Success message: 🎉 Success! Package created: extension-1.0.0.tgz
Before updating package.xml, the script automatically updates version numbers in source code files:
- Search: Scans all .c, .h, and .php files in the source directory
- Pattern Matching: Looks for common version definition patterns
- Update: Replaces old version numbers with the new version
- Report: Lists all files that were updated
The script supports multiple version definition patterns commonly used in PHP extensions.
The script automatically updates these fields:
- Version:
<version><release>and<version><api> - Date:
<date>(current date in YYYY-MM-DD format) - Time:
<time>(current time) - Release Notes:
<notes>(parsed from ChangeLog) - Changelog: Adds new
<release>entry to<changelog>section
The script looks for release notes in your ChangeLog file using these patterns:
Version 1.0.0 - 2024-01-15
- Feature X added
- Bug Y fixed
## 2.1.0
- New feature
It extracts the first version entry found and uses it for release notes.
Verifies all files listed in package.xml exist in the source directory.
Extracts the .tgz to a temporary directory and runs:
phpize
./configure
makeThis ensures the package compiles correctly.
Error: pear package failed
Install PEAR: sudo apt-get install php-pear (Debian/Ubuntu) or equivalent for your system.
Warning: 5 files listed in package.xml are missing
Update package.xml to include all source files, or remove non-existent entries.
phpize failed (may be expected in some environments)
Install PHP development package: sudo apt-get install php-dev (Debian/Ubuntu).
./configure failed
make failed
Check your config.m4 and source files for errors. The package is still created but may have issues.
For detailed information about PECL package structure and standards, see references/pecl_standards.md.
The main packaging script is located at:
scripts/package_pecl.py
This is a Python 3 script that performs all packaging steps automatically.