Linux command
phar 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Add
phar add -f [path/to/archive.phar] [files...]
List
phar list -f [path/to/archive.phar]
Delete
phar delete -f [path/to/archive.phar] -e [file]
Compress
phar compress -f [path/to/archive.phar] -c [gzip|bzip2]
Get info
phar info -f [path/to/archive.phar]
Sign
phar sign -f [path/to/archive.phar] -h [sha256|sha512]
Example
phar help
说明
phar manages PHP Archive (PHAR) files, which bundle PHP applications into single distributable files. PHAR files can include PHP code, assets, and metadata, and can be executed directly by PHP. The tool supports creating, modifying, extracting, and signing PHAR archives. Signing ensures archive integrity and authenticity using hash algorithms or OpenSSL keys.
参数
- -f _archive_
- PHAR archive file to operate on
- -c _algorithm_
- Compression algorithm (gzip, bzip2)
- -h _algorithm_
- Hash algorithm for signing
- -y _keyfile_
- Private key file for OpenSSL signing
- -e _entry_
- Specific entry within archive
FAQ
What is the phar command used for?
phar manages PHP Archive (PHAR) files, which bundle PHP applications into single distributable files. PHAR files can include PHP code, assets, and metadata, and can be executed directly by PHP. The tool supports creating, modifying, extracting, and signing PHAR archives. Signing ensures archive integrity and authenticity using hash algorithms or OpenSSL keys.
How do I run a basic phar example?
Run `phar add -f [path/to/archive.phar] [files...]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f _archive_ do in phar?
PHAR archive file to operate on