I am working on a PHP application which leverages some PEAR packages. I want to be able to package the app in archive (e.g. tar, zip, etc) to be easily downloaded and extracted on servers to run. I do not want the servers to need PEAR for downloading or installing the dependencies. Is there a simple way of packaging the PEAR dependencies with the application?
Okay, you are probably looking for Composer, a tool for dependency management in PHP.
If I understand you correctly, this should do what you want.
There are two ways to deploy (I recommend you provide both options):
Phar
Expanded Directory of Files
In either case, if you are going to be harvesting all of the dependent component files, you can query PEAR for these.
List packages installed by the PEAR installer
pear list
Resulting List
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.7 stable
Console_Getopt 1.3.0 stable
PEAR 1.9.4 stable
Structures_Graph 1.0.4 stable
XML_Util 1.2.1 stable
List files for package XML_Util
pear list-files Archive_Tar # or pear list Archive_Tar
Resulting List
Installed Files For Archive_Tar
===============================
Type Install Path
php /Users/wilmoore/local/php/versions/5.4.0/lib/php/Archive/Tar.php
doc /Users/wilmoore/local/php/versions/5.4.0/lib/php/doc/Archive_Tar/docs/Archive_Tar.txt
From here, it is simply a matter of iterating over that list and harvesting the files. You should be able to skip the lines prefixed with "doc".
Related
Is it possible to list all versions of a pecl package?
pecl search xdebug, for example, only lists the latest 3.0.1 version. But I'm wanting the latest 2.x version.
You can use pecl list to list all installed packages, which will return something like:
Installed packages, channel pecl.php.net:
=========================================
Package Version State
pdo_sqlsrv 5.9.0 stable
redis 5.3.3 stable
sqlsrv 5.9.0 stable
Or, you can use pecl info {package} to list information about a specific package.
So far as I know, you cannot list all available versions directly from command line. Your best bet, is just heading over to pecl.php.net and searching for your package, which will list all package versions, along with their release dates.
The pear command line installer (which is behind pecl) has no native way of listing all package versions.
You can only query the REST API yourself: https://pear.php.net/rest/r/mime_type/allreleases2.xml
The package name must be lowercase in that URL.
You can try this:
pecl install xdebug-2.9.8
I am following this tutorial http://azure.microsoft.com/en-gb/documentation/articles/storage-php-how-to-use-blobs/ on ussing the Azure PHP SDK to access Azure Storage Blobs.
I need to read and write to these blobs from my live Cloud Service running my PHP App. It says that the SDK is dependent on some PEAR Packages and that they should be installed using the "Pear package Installer"
The PHP Client Libraries for Azure have a dependency on the HTTP_Request2, Mail_mime, and Mail_mimeDecode PEAR packages. The recommended way to resolve these dependencies is to install these packages using the PEAR package manager.
This is all well and good on my DEV server, I simply install PEAR and then install the packages. But obviously once the App is packaged and pushed to my Azure Production Cloud Service, it doesn't contain Pear or any of packages. PHP is installed on the Cloud Service when it is spun up using the ServiceDefinition.csdef Startup Tasks. Every new instance has PHP installed on startup.
So how do I get PEAR and these Packages on my Cloud Instance? I have Googled and cannot find anything that explains using Pear on Cloud Instances, yet all the SDK documentation says it is needed?!?
Am I misunderstanding something?
While the PEAR package manager has been a mainstay in days gone by, I think it's rapidly being replaced by Composer and the like.
You don't HAVE to install using the PEAR tool, however. All it is is an early package manager. You can download the PEAR libraries individually and place them in a common directory
http://pear.php.net/package/PEAR/download
The caveat here is that this is 100% manual and all on you to update packages but PEAR updates are few and far between. Download each package and then do something to set the base include directory.
set_include_path('/path/to/pear');
I am working on a mac and trying to install http_request2 and mail_mime via the pear package manager.
When I use the pear install command I see this:
$ pear install http_request2
downloading HTTP_Request2-2.2.1.tgz ...
Starting to download HTTP_Request2-2.2.1.tgz (107,339 bytes)
.........................done: 107,339 bytes
downloading Net_URL2-2.0.5.tgz ...
Starting to download Net_URL2-2.0.5.tgz (17,456 bytes)
...done: 17,456 bytes
install ok: channel://pear.php.net/Net_URL2-2.0.5
install ok: channel://pear.php.net/HTTP_Request2-2.2.1
Which leads me to believe that this is installed correctly. However, if I then run pear list -a I get the following output:
$ pear list -a
Installed packages, channel __uri:
==================================
(no packages installed)
Installed packages, channel doc.php.net:
========================================
(no packages installed)
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.11 stable
Console_Getopt 1.3.1 stable
PEAR 1.9.4 stable
Structures_Graph 1.0.4 stable
XML_Util 1.2.1 stable
Installed packages, channel pecl.php.net:
=========================================
(no packages installed)
http_request2 is not included among the installed packages, despite just being told that it was installed.
I can also run the pear install http_request2 command again and it will not give me the
ignoring installed package pear/http_request2
like it's supposed to, instead it just proceeds with the install.
I ran
pear config-get php_dir
and found http_request2 in that directory.
I tried changing the include_path variable in my php.ini file as suggested in this post: Pear Packages not working but it didn't change anything.
I would prefer not to reinstall pear if possible because I'm not experienced with this and don't want to accidentally end up with two pears, as suggested can happen here: https://stackoverflow.com/a/6596669/2718779. Any suggestions?
You probably stumble across the issue I solved in https://stackoverflow.com/a/19177767/282601 - two versions of pear installed.
I saw this thread which is exactly what I've done as well, Downgraded PHP to version 5.2 on Ubuntu 10.4
When running as root I just get the download, no install message, any thoughts?
pear install Mail_Mime-1.8.0.tgz
downloading Mail_Mime-1.8.0.tgz ...
Starting to download Mail_Mime-1.8.0.tgz (31,292 bytes)
.........done: 31,292 bytes
I've looked in the phpinfo() and see nothing except the pear path
include_path .:/usr/share/php:/usr/share/pear .:/usr/share/php:/usr/share/pear
running pear list I get this
pear list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.3 stable
Console_Getopt 1.2.3 stable
PEAR 1.9.0 stable
Structures_Graph 1.0.2 stable
XML_Util 1.2.1 stable
please manual download Mail_Mime files and extract to /usr/share/pear/
Found a work around, not the best solution but it works. Using the Ubuntu Download Center, search for pear and install the needed packages. Most are listing with a prepending php-
php-mail
after I installed a package with pear, i would like to know what files this package installed. how can i check that?
thanks
If you installed the package via the pear installer (for example with "pear install package-name" at the command line), then you just need to do:
$ pear list package-name
It will also tell you what type of files they are (test scripts, documentation, data etc.)
If the package is from a different channel than pear.php.net, prefix the package name with the channel name and /:
$ pear list channel-name/package-name
It would be easiest just to go to the pear folder and look for the folder of the package you just installed. I don't think pear has a built in utility for this.
#People downvoting. I think you misunderstand. He doesn't want to know what packages he has, he wasn't to know the specific files the packages add.