如何熟悉PEAR的Channel(频道)?

PHP

1 基础知识

1.1 什么是频道

– 频道是PEAR和Pyrus用于安装的网站
– 频道提供Pear的下载安装包
– 频道提供额外的元信息文件
– 熟悉的频道有pear.php.net

1.2 频道的标准

– 频道的根目录应该包含channel.xml文件,例如http://pear.php.net/channel.xml
– 频道包含REST范例,即Representational State Transfer,用于描述安装包和下载,例如,http://pear.php.net/rest
– 另外,还可能包含XML-RPC函数(不建议使用)

2 最佳实践

2.1 验证频道

pear channel-discover pear.phing.info

如果显示如下,则以下频道被自动添加

Adding Channel "pear.phing.info" succeeded
Discovery of channel "pear.phing.info" succeeded

2.2 删除频道

pear channel-delete pear.phing.info

显示如下:

Channel "pear.phing.info" deleted

2.3 手动添加频道

wget pear.phing.info/channel.xml
pear channel-add channel.xml

显示如下则添加成功:

Adding Channel "pear.phing.info" succeeded

2.4 列出已有的频道

pear list-channels 

显示如下:

Registered Channels:
====================
Channel      Alias   Summary
doc.php.net  phpdocs PHP Documentation Team
pear.php.net pear    PHP Extension and Application
                     Repository
pecl.php.net pecl    PHP Extension Community Library
__uri        __uri   Pseudo-channel for static packages

2.5 获取频道的详细信息

pear channel-info pear.php.net

显示如下:

Channel pear.php.net Information:
=================================
Name and Server         pear.php.net
Alias                   pear
Summary                 PHP Extension and Application Repository
Validation Package Name PEAR_Validate
Validation Package      default
Version
Server Capabilities
===================
Type Version/REST type Function Name/REST base
rest REST1.0           http://pear.php.net/rest/
rest REST1.1           http://pear.php.net/rest/
rest REST1.3           http://pear.php.net/rest/

2.6 使用频道上的包

pear install pear/XML_DTD

2.7 使用密码保护的频道

pear channel-discover pear.company.com

如果遇到提示需要认证,

Discovery of channel "pear.company.com" failed
 (channel-add: Cannot open "http://pear.company.com/channel.xml"
 (File http://pear.company.com:80/channel.xml not valid
 (received: HTTP/1.1 401 Authorization Required
)))

请直接下载channel.xml并添加频道,

wget http://pear.company.com/channel.xml
pear channel-add channel.xml

设置频道的账号密码:

$ pear config-set -c pear.company.com username johndoe
$ pear config-set -c pear.company.com password secret

尝试列举频道的包,

pear list-all -c pear.company.com

如果显示如下则认证成功,

Retrieving data...0%
All packages [Channel pear.company.com]:
==========================
Package             Latest Local
comp/WorldDominator 0.8.1        Tool to dominate the world

参阅文档:
================
https://pear.php.net/manual/en/guide.users.commandline.channels.php

没有评论

发表评论

PHP
如何编译安装PHP-FPM?

1 前言 一个问题,一篇文章,一出故事。 PHP-FPM可以跟Nginx配合使Nginx环境具备运行 …

PHP
如何编译安装Apache+PHP8.1.1?

1 前言 笔者平素不喜欢简单的编译安装,因为很多系统管理员为了省事,编译安装的东西没有rpm包安装那 …

Apache
如何编译安装Apache+PHP7.4.3?

1 前言 笔者平素不喜欢简单的编译安装,因为很多系统管理员为了省事,编译安装的东西没有rpm包安装那 …