what is the use of go-pear.php ? What it does actually? - php

Can anybody tell me why do we need to install a set of classes using a script ?
PHP PEAR Lib is essentially a set of classes, is it fairly good to just copy in the hosting server.
So is go-pear.bat go-pear.php is necessary or its an optional. If it is necessary would like to know why?

It is only a tool to help install PEAR classes for all users on the machine.
If you are only going to use a PEAR class in a single project, you can easily just grab the class from it's download page and bundle it with the app.

Related

PEAR: Using the framework in a distributable application

I am working on a PHP application that uses many features from PEAR. The app is meant to be distributable kind of like Wordpress but really scaled down.
Now the problem I've run into is that PEAR needs to be installed and configured alongside the PHP server without which my app simply will not function unless the users go through all the painful steps of installing PEAR on their server. Users can very well be newbies or non-technical so it's not an option for them.
Therefore there is a need to somehow package everything PEAR into the application itself. As far as I know it may not be possible.
Are there any alternate solution to this? Any solution at all will help. Thanks..
PEAR installs system wide dependencies which makes things like what you describe hard. Composer on the other hand is exactly what you'd need, because it's a per-project dependency manager with much better support for resolving and installing of dependencies. Basically, compared to Composer, PEAR sucks... it always did, Composer on the other hand rocks!
The first thing I would do for each package you need is to see if it is also provided on https://packagist.org/. If it is, problem solved, include the installation into your build process with composer. If you end up with only a few packages from PEAR, you have several options:
inspire the author to provide it on packagist
make your own mirror on packagist (not recommended but sometimes necessary)
see if the project is on github and install directly from git with composer
install the PEAR package via composer anyways, it's possible.
Short answer: switch to composer!
If you are talking about the PEAR packages or class files, you can put the PEAR packages anywhere you want. Just put the ones you use into a dir within your app dir structure and add that to the include path.

How to include PEAR packages by only including the PEAR.php file?

I'm using PEAR on a hosted website and I want to use the MDB2 package.
Every site on the web initializes the MDB2 package with an require('MDB2.php').
Sadly, my web host only provides to me the location of the main PEAR.php file.
But I think I remember a method of including PEAR packages without specifically including them by file name, but using the global PEAR class by calling some static function.
Sadly I ran through the documentation several times and tried to Google every combination of keywords that could help me find the solution but I didn't find it.
So, is this possible?? And if so, how do I do so??
Thanks a lot, I've been looking for multiple hours now :(
Steven
No, it is not possible to load pear packages through the PEAR class.
The only official way to include a pear package is to require/include the file you want to use:
require_once 'MDB2.php';
Also, your web host probably will not have MDB2 installed, so you need to ship it yourself. See the installation on a shared host manual.

PHP Pear Package Depndencies Issue

I'm having some trouble with my hosting provider -- put simple they won't enable a dynamic library -- so I turn to PEAR for the PHP library of BBCode. Problem now is it's so loosely coupled to other PEAR classes that's almost impossible for me to even know where to begin. So my question is, is there a particular method in PEAR to automatically zip a package and its dependencies out so that the class can be used fully?
Thanks
Mike
The obvious way would be to just upload your local PEAR folder to the remote system and make sure its on the include path. However, you can also install and manage a PEAR installation on a shared host via PEAR_RemoteInstaller and other means.
See Installation of a local PEAR copy on a shared host for instructions.
I think no auto logic... you have to includes your PEAR directory based on logic
use IF ELSE or SWITCH CASE statment to set up your logic to include or require that..
thanks

A way to do unit testing online? (i.e. Google)?

I'm trying to setup phpUnit via my host however, they are severely outdated and the documentation on how to use it is non-existent (hosts version). I'm wondering is there a way to do online unit testing, where the framework is hosted somewhere other than my server?
For example does Google have a solution where I can just include a file from Google's server?
UPDATE:
OK so apparently there is no cloud based way to run phpUnit. So my problem is installing it. My host has a PEAR installer (I'm not familiar with how PEAR really works yet). However, the version that they have is phpUnit2 which is apparently related to phpUnit (https://github.com/sebastianbergmann/phpunit/). But that is all I can really find.
According to the above link, the main way to install phpUnit is through PEAR :
http://www.phpunit.de/manual/current/en/installation.html
It requires that I change channels, however, it doesn't look like I have access to do that. Some are suggesting I can just copy the files up to my server and use them that way. Is that the best way for me to do this? Are there other settings I need to change (on my server) to make this work?
Any information is much appreciated.
If I'm understanding your question correctly, there's no need to use your host's version; the entire library is just a simple file. Go download it yourself from sourceforge, upload it to your server, and you should be off and running.
I doubt that you will find something like this because in order to unit test a system you need to have access to the code and a remote site isn't able to get that access (i.e. the ability to call functions built into your application).

XML/Parser.php installation

I recently signed up to shared web hosting with godaddy using Linux and PHP 5. I want to work with multiple RSS feeds. I previously had this all functioning under Apache, however, the host supplied the PEAR installation. Now I have to do this myself and I am in unfamiliar territory.I installed PEAR PHP and managed to get rss.php in the pear directory. It now asks for XML/Parser.php and I do not want to spend another week finding where and what to do.
Can you please inform me where i can find this routine and whther there is any problem in just copying it into the PEAR directory with ftp?
You can always just create some subfolder in your project and extract any PEAR libraries directly there, it's just plain php scripts. You will have to add that folder (and subfolders) to your include path so everything will be accessible.
It is considered as a bad practice because you will have to manually update PEAR libraries and stuff, but it gives you independence from your hoster.
Your PEAR (or other libraries) classes can be anywhere. You just need to set correct include paths where script will search for required code. If you can't access php.ini, you can get include paths by using get_include_path() function and set them using set_include_path();
I highly recommend SimplePie feed parser over the PEAR::XML_Feed_Parser. Usually the PEAR libraries are great but they don't support several common types of feeds (I believe Atom 0.3 among several others). Also there is very little documentation about how to use it and (clearly) how to install it.
Simply include the SimplePie library and point it at your feed and it does the rest. It's easy to query for any data you want regardless of schema differences. It's also very fast, we're using it to aggregate hundreds of feeds over at http://www.feedscrub.com.
Hope that helps!
echo ini_get('include_path');
This should show the include the path to PEAR on the original host environment, from there if its not to big just wrap the entire mess up with tar -cjzf devPear.tar.bz path2pear/ .
Copy this tar file over to GoDaddy, extract to a safe location... then in .htaccess or at the start point of your application scripts, add this pear package into your include_path.
Alternatively:
If you have administrative rights, I believe there is a pear.php command called "installed" that shows all installed pear packages. If you also have pear administrative rights on the new environment, you can go down the line doing copy and paste of the package names you need to pear --install "package" name.
The second is a little cleaner, but the first will be faster... just accept these packages will be effectively stranded from the pear system and unable to be updated.

Categories