InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

Menu
  • Home
  • Sitemap

Python Programming Language Best Tutorials and Code Examples

Learn Python Right Now!
Home
PHP
Installing PEAR Packages in PHP
PHP

Installing PEAR Packages in PHP

InfinityCoder December 27, 2016

You want to install a PEAR package.

Download and install the package from the PEAR Channel server using Pryus:

1
% php pyrus.phar install pear/Package_Name

You can also install from another PEAR Channel:

1
% php pyrus.phar install channel/Package_Name

You can also install from any location on the Internet:

1
% php pyrus.phar install http://pear.example.com/Package_Name-1.0.0.tgz

Here’s how to install if you have a local copy of a package:

1
% php pyrus.phar install Package_Name-1.0.0.tgz

To install PEAR packages, you need write permission where the packages are stored; this defaults to /usr/local/lib/php/.
You can also request multiple packages at the same time:

1
2
3
4
5
6
7
8
9
10
% php pyrus.phar install pear/XML_RSS pear/XML_SVG
 
Pyrus version 2.0.0a4 SHA-1: 72271D92C3AA1FA96DF9606CD538868544609A52
Using PEAR installation found at /Users/rasmus/lib
Downloading pear.php.net/XML_RSS
Mime-type: application/octet-stream
Downloading pear.php.net/XML_SVG==============================>] 100% ( 6/ 6 kb)
Mime-type: application/octet-stream
Installed pear.php.net/XML_RSS-1.0.2==========================>] 100% ( 7/ 7 kb)
Installed pear.php.net/XML_SVG-1.1.0

When installing a package, Pyrus checks that you have all the necessary PHP functions and PEAR packages that the new package depends on.

If this check fails, it installs all required PEAR dependencies:

1
2
3
4
5
6
7
8
9
10
11
12
13
% php pyrus.phar install pear/XML_XUL-alpha
 
Pyrus version 2.0.0a4 SHA-1: 72271D92C3AA1FA96DF9606CD538868544609A52
Using PEAR installation found at /Users/rasmus/lib
Downloading pear.php.net/XML_XUL
Mime-type: application/octet-stream
Downloading pear.php.net/XML_Util2===========================>] 100% (26/26 kb)
Mime-type: application/octet-stream
Downloading pear.php.net/XML_Parser2=========================>] 100% (16/16 kb)
Mime-type: application/octet-stream
Installed pear.php.net/XML_XUL-0.9.1=========================>] 100% (11/11 kb)
Installed pear.php.net/XML_Util2-0.1.0
Installed pear.php.net/XML_Parser2-0.1.0

Once a PEAR package is installed, use it in your PHP scripts by calling require_once.
For example, here’s how to include the HTTP_Request2 package:

1
require_once 'HTTP/Request2.php';

Generally, if a package name contains an underscore, replace it with a slash, and add .php to the end.
Because PEAR packages are included as regular PHP files, make sure the directory containing the PEAR packages is in your include_path.

If it isn’t, include_once and require_once can’t find PEAR class files.

Share
Tweet
Email
Prev Article
Next Article

Related Articles

Generating Predictable Random Numbers in PHP
You want to make the random number generate predictable numbers …

Generating Predictable Random Numbers in PHP

Avoiding Regular Expressions in PHP
You want to improve script performance by optimizing string-matching operations. …

Avoiding Regular Expressions in PHP

About The Author

InfinityCoder
InfinityCoder

Leave a Reply

Cancel reply

Recent Tutorials InfinityQuest

  • Adding New Features to bash Using Loadable Built-ins in bash
    Adding New Features to bash Using Loadable …
    June 27, 2017 0
  • Getting to the Bottom of Things in bash
    Getting to the Bottom of Things in …
    June 27, 2017 0

Recent Comments

    Categories

    • Bash
    • PHP
    • Python
    • Uncategorized

    InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

    About Us

    Start learning your desired programming language with InfinityQuest.com.

    On our website you can access any tutorial that you want with video and code examples.

    We are very happy and honored that InfinityQuest.com has been listed as a recommended learning website for students.

    Popular Tags

    binary data python CIDR convert string into datetime python create xml from dict python dictionary into xml python how to create xml with dict in Python how to write binary data in Python IP Address read binary data python tutorial string as date object python string to datetime python

    Archives

    • June 2017
    • April 2017
    • February 2017
    • January 2017
    • December 2016
    • November 2016
    Copyright © 2019 InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more
    Programming Tutorials | Sitemap