I’d like to ask for some help getting Pear’s PHP Code Sniffer set up properly.
I’m using MAMP pro 2.0.5 on a Mac PB 10.7.4 with PHP 5.3.6.
I do have Pear installed and can run pear commands, when I installed the PHP_CodeSniffer channel I didn’t get any errors but I can’t trigger any commands.
Here is a screen shot of my command line:
https://skitch.com/stephanief0042/etuck/alohamediaworks-bash-100x40
I was able to reference this post:
Putting PEARs php_dir into include_path in php.ini
But my include path seems correct:
include_path = ".:/Applications/MAMP/bin/php/php5.3.6/lib/php:/Applications/MAMP/bin/php/php5.3.6/bin/pear"
When I traced the path to the PHPCS install I found it’s executable file on this path: Users/alohamediaworks/pear/bin/phpcs
I’m not sure if i’m one symlink from being able to use this or not, any help or suggestions would be welcome.
PEAR will install bin files like PHPCS into a configurable location. You can see this location by running pear config-show | grep bin_dir.
The value here is probably currently /Users/alohamediaworks/pear/bin
You might want to just set it to /Applications/MAMP/bin or somewhere local on your Mac, like /usr/local/bin.
Before you do this, it is worth uninstalling PHP_CodeSniffer, and also checking that PEAR knows where PHP is by running pear config-show | grep php_bin.
I'll assume both values need changing:
pear uninstall PHP_CodeSniffer
pear config-set bin_dir /Applications/MAMP/bin/php/php5.3.6/bin
pear config-set bin_dir /Applications/MAMP/bin
pear install PHP_CodeSniffer
(check that the paths are valid first and that you don't have friendlier symlink versions)
You need the php_bin to be correct because PEAR will change the #! line of all bin files (like phpcs) on install to point to your PHP executable. The bin_dir is important to ensure bin files are placed into a directory that is in your path. Uninstalling PHP_CodeSniffer is required so old files are not left around (PEAR wont move them).
Hope that helps.
Related
I'm using Batavi to build an online store, and when I install it is giving error like
PEAR is not installed on this server or path to a directory with PEAR is not specified in the include_path.
and another error like
Version of Apache on your server has been hidden.
I don't have any idea how to set it up, may be with php.ini file, can some one help me?
Depending on your operating system probably there should be a pear package.
For example on ubuntu linux it is php-pear, and you can install it like this:
sudo apt-get install php-pear
If pear is only missing from your include_path, you should add it in your php.ini files. (somewhere around /etc/php*)
In my case /etc/php5/*/php.ini:
include_path = ".:/usr/share/php"
But you should verify the path.
After I tried for hours to find the good path for PHP-CLI, i finally found it. But my proud was soon gone again.
Still i got the following error:
The following requirements were not met. As a result video uploads have been disabled.
Unable to locate path to PHP-CLI
I have tried much different paths
bin/php
usr/local/lib
usr/local/lib/php
usr/local/bin/php (this is the good one I thought).
Still getting the same error as above. Whats happening? My server is not running in Safe Mode and my exec() are enabled via the php.ini file.
Please help me..
Edit:
Paul
Q: Have you tried any "fully qualified paths", e.g. "/bin/php" (not
just "bin/php")?
A: I have tried both solutions, no result.
Q: Are you sure php-cli is installed on your system (it's typically a
seperate package from the Apache PHP plug-in)? EXAMPLE: apt-get
install php5-common libapache2-mod-php5 php5-cli.
A: I tried this in the SSH of my server, its a CentOS server so he didn't found the comment
#Peter:
If you installed PHP through your OS package manager, the path would
probably be /usr/bin/php, which appears to be the only one you didn't
try
I tried that one now, i didn't help, still the same error:
Edit2
#Dev-null
You have found and what? Just knowing where >is located will not fix it, have you changed some >code or environment variable PATH to make it
A: its an input field where i need to put the path in. I haven't changed any code, because PHP version 5.3.17 (CLI) installed on my CentOS server. So no need to change some code just for the path, right?
Edit
My PHP info, PHP 5.3.17 (CLI) Check the image below..
Edit
When I do rpm -q php-cli I get PHP-CLI not installed and when I want to install i get No package php-cli available. See image below.
Edit
Result of /bin/php -v below.
CentOS ships the PHP command-line interpreter in the php-cli package. So you first need to verify whether it's installed or not:
rpm -q php-cli
If installed, you can list all its files:
rpm -ql php-cli
... and filter out potential binaries:
rpm -ql php-cli | grep /bin/
You can get further details in the Using RPM chapter of the deployment guide.
If the package is not installed:
yum install php-cli
More info at Installing New Software with yum.
All this answer assumes that nobody broke the package system by installing software manually. If that happened, there's no way to tell what changes were made to the system.
Edit #1: I've just seen your last edit where php-cli is up and running. Then, if you want to know the path you just need to type this:
which php
Edit #2: You seem to have up to 4 binaries called php in your path. I still think that the proper reliable way to find the php-cli binary is running rpm -ql php-cli but given that php finds it on the path I'm pretty sure that it's located at /bin/php and you can verify it by running:
/bin/php -v
Run that exact command—don't remove any slashes or append -cli.
If your script, whatever it looks like, cannot find it, it's either doing it wrong or it's missing the appropriate permissions.
try the following to find it:
sudo find / -name php-cli
You most likely want php instead of php-cli though.
None of the solutions on this page found the installed versions of PHP that were present in my own elusive search for php-cli. The solution for me was to use the following command:
locate bin/php
This listed all php versions and I could then replace php with, for example:
/usr/bin/php71-cli
To access the command line interface version of php rather than the default cgi one. I then alias my instructions like so:
alias composer='/usr/bin/php71-cli bin/composer.phar'
I installed "drush" for my drupal website.
when I tried to run "drush":
[root#server /]# drush
/usr/share/drush/drush.launcher: line 132: /usr/bin/php-cli: No such file or directory
[root#server /]#
php-cli was not in my default directory /usr/bin
Solution was to copy my "php"-file to "php-cli" file (no rename!!, just copy)
[root#server /]# cp php php-cli
weird, but still working!
I currently have a linux server with Plesk installed. I need to have pear functionality, however I'm having difficulty understanding the documentation.
Viewing phpinfo(), the configure command contains --without-pear.
I have 'edited' my httpd.include file to extend the openbase_dir value to /usr/share/pear and also used this in the include path.
In the pear manual, it states:
When using PHP, the PEAR Package Manager is already installed unless one has used the ./configure option --without-pear.
Does this mean I need to install the pear package manager again? Do I need to reconfigure PHP with --with-pear? If so how do I do this?
After this step, is there anything else I need to do to enable pear?
Many thanks
Phil
Personally, I have just manually installed PEAR with an apt-get install php-pear and then I included it in php parameter in each domains and subdomains on my plesk panel. So I added /usr/share/php (which is PEAR directory, you can get it with pear config-get php_dir) in include_path and open_basedir sections (you can see here how to manage PHP settings on plesk).
I'm developing an application in PHP on a Linux server. The server has at least two different versions of php installed on it: 5.2.0 and 5.2.9.
The 5.2.0 version has the following directory /usr/local/lib/php in the include_path in php.ini.
I need to find out where the 5.2.9 version of this directory is located.
I checked the include_path setting in the 5.2.9 php.ini but it only has . and /usr/share/pear for include_path.
(Note that I just installed pear right now, since the 5.2.9 php was originally configured without pear.) The files in /usr/share/pear do not seem to match what I see in /usr/local/lib/php and it seems a little absurd to tell pear that php_dir is /usr/share/pear. Any ideas?
UPDATE - Is it possible that /usr/local/lib/php also belongs to php 5.2.9? Is there anything within this directory itself I can look at, to see?
If the directory you're looking for exists (it might not if you excluded pear during install): The default location would be /xxx/lib/php where /xxx is the installation prefix.
For example, on one of my servers, one of my PHP executables (I have 4 versions installed) is located /custom/php5.3.5/bin/php so it's corresponding PEAR/general library directory is /custom/php5.3.5/lib/php
(/custom/php5.3.5 being the installation prefix, normally it would be /usr/local or /usr.)
If your lib/php directory has a pearcmd.php file, call (yourphpbin) pearcmd.php info pear and it should be able to tell you pear version, it's requirements and whatnot. (If pearcmd.php exists, there's a good chance pear exists in that directory.) The pear shell-script would by default be at /xxx/bin/pear again /xxx being the installation prefix.
As far as I'm aware, you can set it up so that PEAR is shared among multiple versions of PHP. I would assume that's how the /usr/share/pear one is set up. (Distribution repository-provided?) Not sure if the same holds true for pecl. If you have multiple installs of pear, you just need to make sure you install the packages you want to use into the right pear install.
PHP will happily use whatever PEAR installation you tell it to in include_path.
Try the whereis command. It usualy gets you the binary, man page and configuration paths.
$ whereis php
You can then check the information each PHP version outputs:
$ /path/to/php.binary -i
There should be information about the included paths and configuration files used.
To find it, use:
]# sudo updatedb
]# locate php
That might return LOTS of results, you can filter in various ways. I usually try this first:
]# locate php | grep bin
You can try this command in the console:
which php
I'm using Macports for my PHP development. I thought that everything associated with Macports should be located under/opt/local, but I can't load the PEAR::Mail_Mime package I just installed through PEAR. I did confirm that the path to pear is /opt/local/bin/pear, but I have no idea where it dumped the package files, so I don't know how to include them in my path. Any pointers?
If you used the pear command to install the package, you could also do
$ pear list mail_mime
to get a listing of all files from that package and where they were installed to. It's a handy way of looking for example files, especially when used with grep ;-)
Pear files are typically installed in a share/php directory although I'm not on my mac right now so I can't check exactly where that might be. You can find that directory using locate though. From your terminal type:
$ locate PEAR.php
It should return something like /usr/share/php/PEAR.php - In this example /usr/share/php should be in my include path. Mail.php and Mail/mime.php should also be in this directory.