admin管理员组

文章数量:1794759

PHP官方扩展安装程序PIE发布 0.1.0 预览版

概述

PIE是PHP官方推出的PHP扩展安装程序<您需要 PHP 8.1 或更高版本才能运行 PIE,但 PIE 可以安装任何已安装的 PHP 版本的扩展。

安装 PIE

下载

代码语言:javascript代码运行次数:0运行复制
wget .1.0/pie.phar

Connecting to github (20.205.243.166:443)
Connecting to objects.githubusercontent (185.199.109.133:443)
saving to 'pie.phar'
pie.phar             100% |***********************************************************************************************************************************| 5921k  0:00:00 ETA
'pie.phar' saved

添加PATH

代码语言:javascript代码运行次数:0运行复制
sudo cp pie.phar /usr/local/bin/pie

sudo chmod +x /usr/local/bin/pie

使用 PIE

代码语言:javascript代码运行次数:0运行复制
php pie.phar <command>

或者 

pie  <command>

例如帮助命令help

代码语言:javascript代码运行次数:0运行复制
/usr/local/php-8.2.14/bin/php pie.phar --help

# pie --help

Description:
  List commands

Usage:
  list [options] [--] [<namespace>]

Arguments:
  namespace             The namespace name

Options:
      --raw             To output raw command list
      --format=FORMAT   The output format (txt, xml, json, or md) [default: "txt"]
      --short           To skip describing commands' arguments
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  The list command lists all commands:

    pie.phar list

  You can also display the commands for a specific namespace:

    pie.phar list test

  You can also output the information in other formats by using the --format option:

    pie.phar list --format=xml

  It's also possible to get raw list of commands (useful for embedding command runner):

    pie.phar list --raw

支持 PIE 的扩展

可以在 上找到支持 PIE 的扩展列表。

使用 PIE 安装扩展

您可以使用 install 命令安装扩展。例如:要安装 example_pie_extension Redis扩展,您可以运行:

代码语言:javascript代码运行次数:0运行复制
php pie.phar install example/example-pie-extension

安装apcu扩展

下来通过安装apcu扩展来演示如何通过PIE 安装扩展

安装包仓库地址:

代码语言:javascript代码运行次数:0运行复制
sudo /usr/local/php-8.2.14/bin/php pie.phar install --with-php-config=/usr/local/php-8.2.14/bin/php-config apcu/apcu

You are running PHP 8.2.14
Target PHP installation: 8.2.14 nts, on Linux/OSX/etc x86_64 (from /usr/local/php-8.2.14/bin/php)
Found package: apcu/apcu:v5.1.24 which provides ext-apcu
phpize complete.
Configure complete with options: --with-php-config=/usr/local/php-8.2.14/bin/php-config
Build complete: /tmp/pie_downloader_670749ede89342.27916651/krakjoe-apcu-62e6798/modules/apcu.so
Install complete: /usr/local/php-8.2.14/lib/php/extensions/no-debug-non-zts-20220829/apcu.so
You must now add "extension=apcu" to your php.ini

注意点

  1. 运行 PIE 需要 PHP 8.1 或更高版本,我这里使用非默认的php-8.2.14
  2. 由于我本地默认安装是 PHP 7.4,所以这里执行文件必须要执行PHP二进制执行文件/usr/local/php-8.2.14/bin/php
  3. 由于安装非默认版本的 PHP 安装扩展,需要使用 --with-php-config 选项指定编译配置为/usr/local/php-8.2.14/bin/php-config

php.ini 添加扩展

代码语言:javascript代码运行次数:0运行复制
vim /usr/local/php-8.2.14/etc/php.ini

# 添加以下内容
extension=apcu

检查是否安装成功

代码语言:javascript代码运行次数:0运行复制
/usr/local/php-8.2.14/bin/php -m |grep apcu

查看安装版本和配置

代码语言:javascript代码运行次数:0运行复制
 /usr/local/php-8.2.14/bin/php --ri apcu

apcu

APCu Support => Disabled
Version => 5.1.24
APCu Debugging => Disabled
MMAP Support => Enabled
MMAP File Mask =>  
Serialization Support => Disabled
Build Date => Oct 10 2024 11:28:53

Directive => Local Value => Master Value
apc.enabled => On => On
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.ttl => 0 => 0
apc.smart => 0 => 0
apc.mmap_file_mask => no value => no value
apc.enable_cli => Off => Off
apc.slam_defense => Off => Off
apc.preload_path => no value => no value
apc.coredump_unmap => Off => Off
apc.use_request_time => Off => Off
apc.serializer => php => php

版本约束和稳定性

在使用 PIE 安装扩展时,您可以选择指定版本约束:

代码语言:javascript代码运行次数:0运行复制
pie install <vendor>/<package>:<version-constraint>
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。原始发表:2024-10-10,如有侵权请联系 cloudcommunity@tencent 删除配置phplistlocal二进制

本文标签: PHP官方扩展安装程序PIE发布 010 预览版