Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use pear without installation

Tags:

php

pear

I am developing a script for a site using php and I want to use some PEAR classes as they are very helpful to save me from some repeated tasks.

The Problem is that I have to deliver the project as a standalone folder that will be placed in an existing website without depending on any server configuration other than PHP 5 and MySQL.

So I am looking for an easy way to do that. Can any one help?

like image 589
Sloping Avatar asked Jun 02 '10 17:06

Sloping


2 Answers

You can download the packages (be sure do download any dependencies as well), and put them into a directory. Then, in php, adjust the include path to include that directory:

$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mypear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

Then, you can use pear just like normal (include Mail.php;)...

like image 199
ircmaxell Avatar answered Sep 21 '22 02:09

ircmaxell


You want to use the Pyrus installer: http://pear2.php.net/

It allows you to do this exact thing, multiple PEAR package installs in different locations.

$>php pyrus.phar install /Path/to/project/lib pear/Net_URL

where lib is a directory within your project. The main issue I ran into is while the docs say it's for 5.3+ you need 5.3.1.

  • http://pear.php.net/manual/en/pyrus.php
  • https://pyrus.com/en/help/tasks/getting-started
like image 37
ericras Avatar answered Sep 24 '22 02:09

ericras