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.
Related
I'm trying to fix a bug in a more complex PEAR package (CodeCoverage). So I'd like to have the development version that exists not within my PEAR path:
c:\Programme\PHP\PEAR\PHP
with one on another location, here exemplary:
c:\Dokumente und Einstellungen\hakre\PhpstormProjects\php-code-coverage\PHP\
Is there a common way in PEAR to temporarily switch from the installed package to just the files on another location of the disk?
I tried with placing a symbolic link, but that does not work because I need to link CodeCoverage.php as well which is not possible on Windows XP.
Is there some kind of development switch for this kind of scenario in PEAR or is it just that it's the business of each package to take care of that?
I'm using the CodeCoverage package together with PHPUnit.
I could get it to work by adding it to PHP's include path before the PEAR dir:
include_path = ".;c:\path\to\php-code-coverage;C:\programme\php\pear"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Invoking PHPUnit now uses the standard package but the development version of CodeCoverage. No symbolic linking required, editing php.ini is enough.
The "Contributing" section of the PHPUnit github project has a runner script included to make that task easier for you.
You can ether check out all the repositories from there or, if you only need one, still use the runner script:
#!/bin/bash
php -d include_path='.:../phpunit/:../dbunit/:../php-code-coverage/:../php-file-iterator/:../php-invoker/:../php-text-template/:../php-timer:../php-token-stream:../phpunit-mock-objects/:../phpunit-selenium/:../phpunit-story/:/usr/local/lib/php' ../phpunit/phpunit.php $*
(intentially not formatted as code so the whole thing is shown)
You can adapt the pathes to an absolute one by replacing .. with /path/to/your/dev/folder/ and put the script in /usr/local/bin/ and call it phpunit-dev.
Then it will automatically pick up all the existing folders and fall back to the pear path at the end for everything it can't find.
Another way to get a dev setup quickly would be to install it from composer with minimum-stability: dev and change the remote on one of the repos :)
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.
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
I am developing a Facebook app using heroku. My app needs the ability to upload files (pictures) to a folder on a remote server, and I assume ftp is the best option. Unfortunately the ftp extension is not enabled out of the box. I spoke with support and they suggested the following:
"We unfortunately don't support FTP, or any PHP extension at this moment.
But the good news is that we just open sourced our PHP build pack, so you could try to vendor it yourself:
https://github.com/heroku/heroku-buildpack-php"
So I am assuming I can follow the readme instructions in the link above, and simply include the --enable-ftp option?
This is a bit beyond my current knowledge. I really appreciate the help, and look forward to learning something new.
I had to do something similar. Here's what I did:
1.You need to use a custom buildpack which installs the pear packages Net_FTP. I suggest that you fork the one I've been using (https://github.com/antonyevans/heroku-buildpack-php/)
Then you need to change bin/compile. Key changes are the removal of the lines (around 163):
php/bin/pear install mail
php/bin/pear install Net_SMTP
And the addition of Net_FTP extension:
php/bin/pear install Net_FTP
2.Then you need to tell your application to load the package:
require_once 'Net_FTP.php';
Your biggest problem is that the Heroku file system is emphemeral. I would suggest going back and looking at your architecture again.
I am new to Linux and I am attempting to install the PHP PEAR library on a virtual server which is running Ubuntu. I am following a tutorial that covers installing PEAR but have run up against an area where I am confused. When running the PEAR installation program I am prompted as to what I want the INSTALL_PREFIX to be. Evidently the INSTALL_PREFIX, among other things, determines where PEAR will be installed. The tutorial suggest the value of INSTALL_PREFIX be the following path ...
"/home/MY_USER_NAME/pear"
where MY_USER_NAME = my user account
Having come from a Windows world, applications are installed on the system where everyone can use them. If I install PEAR underneath my user directory will other developers on the system be able to make use of PEAR in their PHP scripts? I want to make PEAR available to all users and not just myself.
Could someone explain to me the difference between installing for all users and installing just for myself? Does the install location matter? Should I be installing PEAR in a different location?
Thanks for any suggestions.
P.S. The tutorial I am following is located at the following URL ...
http://articles.sitepoint.com/article/getting-started-with-pear/2
Amend your INSTALL_PREFIX...
typically PEAR gets installed to /usr/share/php/
Have you read through the install section on the PEAR site?
There is no law against giving others access to your home directory but in practice it is never done. If you wanted to do that you would have to set the correct directory permissions and the other users would need to put your stuff on their PATH. But don't, it's bad if only because others can see all your stuff, accidentally (or maliciously) delete things, etc.
You should read a few things on file system standards and file system hierarchy and figure out what is appropriate for you system. Usually it will be something like /opt or /usr/local which will be accessible to all users. Usually you will need to have root permissions to install in global locations.