特殊:Badtitle/NS100:PhpPear:修订间差异
小 新页面: {{From|https://help.ubuntu.com/community/PhpPear}} {{Languages|UbuntuHelp:PhpPear}} == PHP PEAR Introduction == PHP PEAR is a PHP Extension and Application Repository == Modules == PHP... |
小无编辑摘要 |
||
(未显示2个用户的6个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/PhpPear}} | {{From|https://help.ubuntu.com/community/PhpPear}} | ||
{{Languages|UbuntuHelp:PhpPear}} | {{Languages|UbuntuHelp:PhpPear}} | ||
== PHP PEAR Introduction == | == PHP PEAR Introduction == | ||
PHP PEAR is a PHP Extension and Application Repository | PHP PEAR is a PHP Extension and Application Repository. PEAR is somewhat similar to Perl's [http://www.cpan.org/ CPAN] and Ruby's [http://www.rubygems.org/ RubyGems]. PEAR functions like a Package Manager for PHP code and a whole lot more. | ||
== Installation == | |||
Install the '''php-pear''' package using your favorite Ubuntu package manager. | |||
See [[UbuntuHelp:InstallingSoftware|InstallingSoftware]] for different ways to install the php-pear package. | |||
== Using PEAR == | |||
This section discusses some of the common uses of PEAR. For more detailed instructions on using PEAR see the [http://pear.php.net/manual PEAR Manual] | |||
* Get a list of software available using PEAR | |||
<pre><nowiki> | |||
pear remote-list | |||
</nowiki></pre> | |||
* Install a package | |||
<pre><nowiki> | |||
pear install <package_name> | |||
</nowiki></pre> | |||
* List packages installed | |||
<pre><nowiki> | |||
pear list | |||
</nowiki></pre> | |||
* List files belonging to an installed package | |||
<pre><nowiki> | |||
pear list-files <package_name> | |||
</nowiki></pre> | |||
* Uninstall a PEAR package | |||
<pre><nowiki> | |||
pear uninstall <package_name> | |||
</nowiki></pre> | |||
* Upgrade PEAR installer (needed for installing certain packages) | |||
<pre><nowiki> | |||
pear upgrade PEAR | |||
</nowiki></pre> | |||
== Example == | |||
In this example, we'll install the [http://pear.php.net/package/System_Folders System_Folders] package. System_Folders provides methods to get the locations of various system folders like home directory, desktop folder and "My documents". | |||
* Install System_Folders | |||
<pre><nowiki> | |||
command: | |||
sudo pear install System_Folders | |||
output: | |||
Did not download optional dependencies: pear/XML_Parser, pear/XML_Util, use --alldeps to download automatically | |||
pear/Config can optionally use package "pear/XML_Parser" | |||
pear/Config can optionally use package "pear/XML_Util" | |||
downloading System_Folders-1.0.0.tgz ... | |||
Starting to download System_Folders-1.0.0.tgz (8,364 bytes) | |||
.....done: 8,364 bytes | |||
downloading Config-1.10.11.tgz ... | |||
Starting to download Config-1.10.11.tgz (27,718 bytes) | |||
...done: 27,718 bytes | |||
install ok: channel://pear.php.net/Config-1.10.11 | |||
install ok: channel://pear.php.net/System_Folders-1.0.0 | |||
</nowiki></pre> | |||
Notice PEAR mentions some optional packages to install. | |||
* Double check that System_Folders is installed | |||
<pre><nowiki> | <pre><nowiki> | ||
command: | |||
pear list | |||
output: | |||
Package Version State | |||
System_Folders 1.0.0 stable | |||
</nowiki></pre> | </nowiki></pre> | ||
'''Note:''' You'll probably have other PEAR packages in the list. Some are installed when you install PHP. | |||
* List the files that System_Folders installed | |||
<pre><nowiki> | |||
command: | |||
pear list-files System_Folders | |||
== | output: | ||
Install | Installed Files For System_Folders | ||
================================== | |||
Type Install Path | |||
php /usr/share/php/System/Folders/Cached.php | |||
doc /usr/share/php/docs/System_Folders/examples/cached.php | |||
doc /usr/share/php/docs/System_Folders/examples/example.php | |||
php /usr/share/php/System/Folders.php | |||
</nowiki></pre> | |||
'''Note:''' The path names may vary depending on your system. | |||
* Using System_Folders in a PHP program. | |||
* We'll create a simple PHP script to print the location of your Home folder. | |||
* Open your favorite text editor and add the following: | |||
<pre><nowiki> | <pre><nowiki> | ||
$ | <?php | ||
require_once 'System/Folders.php'; | |||
$sf = new System_Folders(); | |||
$home = $sf->getHome(); | |||
echo "$home\n"; | |||
?> | |||
</nowiki></pre> | </nowiki></pre> | ||
* Save the file as system_folders_test.php (or simply test.php if you're into the whole brevity thing). | |||
* Next execute the script: | |||
<pre><nowiki> | <pre><nowiki> | ||
php system_folders_test.php | |||
</nowiki></pre> | </nowiki></pre> | ||
* If all went well you should see the path to your Home directory printed to the console. | |||
'''Note:''' to execute the above command you'll need to have '''php-cli''' installed on your system. | |||
* If you have Apache or another web server configured to use PHP you could also place the file somewhere in your DocumentRoot and point your browser to it. | |||
* For example: <code><nowiki>http://localhost/test/system_folders_test.php</nowiki></code> | |||
* If after all that you've decided that System_Folders isn't all that useful you can uninstall it by: | |||
<pre><nowiki> | |||
command: | |||
sudo pear uninstall System_Folders | |||
output: | |||
uninstall ok: channel://pear.php.net/System_Folders-1.0.0 | |||
</nowiki></pre> | |||
== NOTES == | == NOTES == | ||
1) | 1) | ||
Some PHP PEAR modules | Some PHP PEAR modules are packaged for installation using Ubuntu package managers, but if the package you're looking for is missing from Ubuntu and you will have to manually install them by using PEAR. See above for instructions. | ||
For example: | |||
<pre><nowiki> | <pre><nowiki> | ||
pear install Image_color | |||
pear install Image_Text | |||
pear install channel://pear.php.net/Image_Text-0.5.2beta2 | |||
</nowiki></pre> | </nowiki></pre> | ||
2) | 2) | ||
If you are trying to use Image_graph you may get | If you are trying to use Image_graph you may get | ||
第65行: | 第130行: | ||
$ | $ | ||
</nowiki></pre> | </nowiki></pre> | ||
'''Note:''' This guide has been tested on Ubuntu 6.06 (Dapper), Ubuntu 7.10 (Gutsy). | |||
---- | ---- | ||
[[category:CategorySoftware]] | [[category:CategorySoftware]] | ||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2008年10月19日 (日) 16:50的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/PhpPear }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/af | • {{#if: UbuntuHelp:PhpPear|Afrikaans| [[::PhpPear/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/ar | • {{#if: UbuntuHelp:PhpPear|العربية| [[::PhpPear/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/az | • {{#if: UbuntuHelp:PhpPear|azərbaycanca| [[::PhpPear/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/bcc | • {{#if: UbuntuHelp:PhpPear|جهلسری بلوچی| [[::PhpPear/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/bg | • {{#if: UbuntuHelp:PhpPear|български| [[::PhpPear/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/br | • {{#if: UbuntuHelp:PhpPear|brezhoneg| [[::PhpPear/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/ca | • {{#if: UbuntuHelp:PhpPear|català| [[::PhpPear/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/cs | • {{#if: UbuntuHelp:PhpPear|čeština| [[::PhpPear/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/de | • {{#if: UbuntuHelp:PhpPear|Deutsch| [[::PhpPear/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/el | • {{#if: UbuntuHelp:PhpPear|Ελληνικά| [[::PhpPear/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/es | • {{#if: UbuntuHelp:PhpPear|español| [[::PhpPear/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/fa | • {{#if: UbuntuHelp:PhpPear|فارسی| [[::PhpPear/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/fi | • {{#if: UbuntuHelp:PhpPear|suomi| [[::PhpPear/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/fr | • {{#if: UbuntuHelp:PhpPear|français| [[::PhpPear/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/gu | • {{#if: UbuntuHelp:PhpPear|ગુજરાતી| [[::PhpPear/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/he | • {{#if: UbuntuHelp:PhpPear|עברית| [[::PhpPear/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/hu | • {{#if: UbuntuHelp:PhpPear|magyar| [[::PhpPear/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/id | • {{#if: UbuntuHelp:PhpPear|Bahasa Indonesia| [[::PhpPear/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/it | • {{#if: UbuntuHelp:PhpPear|italiano| [[::PhpPear/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/ja | • {{#if: UbuntuHelp:PhpPear|日本語| [[::PhpPear/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/ko | • {{#if: UbuntuHelp:PhpPear|한국어| [[::PhpPear/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/ksh | • {{#if: UbuntuHelp:PhpPear|Ripoarisch| [[::PhpPear/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/mr | • {{#if: UbuntuHelp:PhpPear|मराठी| [[::PhpPear/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/ms | • {{#if: UbuntuHelp:PhpPear|Bahasa Melayu| [[::PhpPear/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/nl | • {{#if: UbuntuHelp:PhpPear|Nederlands| [[::PhpPear/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/no | • {{#if: UbuntuHelp:PhpPear|norsk| [[::PhpPear/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/oc | • {{#if: UbuntuHelp:PhpPear|occitan| [[::PhpPear/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/pl | • {{#if: UbuntuHelp:PhpPear|polski| [[::PhpPear/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/pt | • {{#if: UbuntuHelp:PhpPear|português| [[::PhpPear/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/ro | • {{#if: UbuntuHelp:PhpPear|română| [[::PhpPear/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/ru | • {{#if: UbuntuHelp:PhpPear|русский| [[::PhpPear/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/si | • {{#if: UbuntuHelp:PhpPear|සිංහල| [[::PhpPear/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/sq | • {{#if: UbuntuHelp:PhpPear|shqip| [[::PhpPear/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/sr | • {{#if: UbuntuHelp:PhpPear|српски / srpski| [[::PhpPear/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/sv | • {{#if: UbuntuHelp:PhpPear|svenska| [[::PhpPear/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/th | • {{#if: UbuntuHelp:PhpPear|ไทย| [[::PhpPear/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/tr | • {{#if: UbuntuHelp:PhpPear|Türkçe| [[::PhpPear/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/vi | • {{#if: UbuntuHelp:PhpPear|Tiếng Việt| [[::PhpPear/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/yue | • {{#if: UbuntuHelp:PhpPear|粵語| [[::PhpPear/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/zh | • {{#if: UbuntuHelp:PhpPear|中文| [[::PhpPear/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/zh-hans | • {{#if: UbuntuHelp:PhpPear|中文(简体)| [[::PhpPear/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PhpPear | UbuntuHelp:PhpPear | {{#if: | :}}PhpPear}}/zh-hant | • {{#if: UbuntuHelp:PhpPear|中文(繁體)| [[::PhpPear/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:PhpPear|:PhpPear|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :PhpPear/zh | | {{#ifexist: PhpPear/zh | | {{#ifeq: {{#titleparts:PhpPear|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:PhpPear|1|-1|}} | zh | | }}
PHP PEAR Introduction
PHP PEAR is a PHP Extension and Application Repository. PEAR is somewhat similar to Perl's CPAN and Ruby's RubyGems. PEAR functions like a Package Manager for PHP code and a whole lot more.
Installation
Install the php-pear package using your favorite Ubuntu package manager. See InstallingSoftware for different ways to install the php-pear package.
Using PEAR
This section discusses some of the common uses of PEAR. For more detailed instructions on using PEAR see the PEAR Manual
- Get a list of software available using PEAR
pear remote-list
- Install a package
pear install <package_name>
- List packages installed
pear list
- List files belonging to an installed package
pear list-files <package_name>
- Uninstall a PEAR package
pear uninstall <package_name>
- Upgrade PEAR installer (needed for installing certain packages)
pear upgrade PEAR
Example
In this example, we'll install the System_Folders package. System_Folders provides methods to get the locations of various system folders like home directory, desktop folder and "My documents".
- Install System_Folders
command: sudo pear install System_Folders output: Did not download optional dependencies: pear/XML_Parser, pear/XML_Util, use --alldeps to download automatically pear/Config can optionally use package "pear/XML_Parser" pear/Config can optionally use package "pear/XML_Util" downloading System_Folders-1.0.0.tgz ... Starting to download System_Folders-1.0.0.tgz (8,364 bytes) .....done: 8,364 bytes downloading Config-1.10.11.tgz ... Starting to download Config-1.10.11.tgz (27,718 bytes) ...done: 27,718 bytes install ok: channel://pear.php.net/Config-1.10.11 install ok: channel://pear.php.net/System_Folders-1.0.0
Notice PEAR mentions some optional packages to install.
- Double check that System_Folders is installed
command: pear list output: Package Version State System_Folders 1.0.0 stable
Note: You'll probably have other PEAR packages in the list. Some are installed when you install PHP.
- List the files that System_Folders installed
command: pear list-files System_Folders output: Installed Files For System_Folders ================================== Type Install Path php /usr/share/php/System/Folders/Cached.php doc /usr/share/php/docs/System_Folders/examples/cached.php doc /usr/share/php/docs/System_Folders/examples/example.php php /usr/share/php/System/Folders.php
Note: The path names may vary depending on your system.
- Using System_Folders in a PHP program.
- We'll create a simple PHP script to print the location of your Home folder.
- Open your favorite text editor and add the following:
<?php require_once 'System/Folders.php'; $sf = new System_Folders(); $home = $sf->getHome(); echo "$home\n"; ?>
- Save the file as system_folders_test.php (or simply test.php if you're into the whole brevity thing).
- Next execute the script:
php system_folders_test.php
- If all went well you should see the path to your Home directory printed to the console.
Note: to execute the above command you'll need to have php-cli installed on your system.
- If you have Apache or another web server configured to use PHP you could also place the file somewhere in your DocumentRoot and point your browser to it.
- For example:
http://localhost/test/system_folders_test.php
- If after all that you've decided that System_Folders isn't all that useful you can uninstall it by:
command: sudo pear uninstall System_Folders output: uninstall ok: channel://pear.php.net/System_Folders-1.0.0
NOTES
1) Some PHP PEAR modules are packaged for installation using Ubuntu package managers, but if the package you're looking for is missing from Ubuntu and you will have to manually install them by using PEAR. See above for instructions. For example:
pear install Image_color pear install Image_Text pear install channel://pear.php.net/Image_Text-0.5.2beta2
2) If you are trying to use Image_graph you may get
Warning: imagettfbbox() [function.imagettfbbox]: Could not find/open font in /mnt/sites/asmtennis.net/web/PEAR/Image/Canvas/GD.php
unless you have installed TrueType fonts and created a symbolic link to them
$ sudo -i # cd /usr/share/php/Image/Canvas # ln -s /usr/share/fonts/truetype/msttcorefonts/ Fonts $
Note: This guide has been tested on Ubuntu 6.06 (Dapper), Ubuntu 7.10 (Gutsy).