El Capitan pear command not found - macos

I am new to mac and am trying to get pear to run from the terminal.
All the scripts are added to the MAMP folder and if I run:
$ sudo /Applications/MAMP/bin/php/php5.6.10/bin/pear
everything is fine.
However, if I run $sudo pear or pear I get a message: "pear command not found"
My $PATH variable looks like this:
/Applications/MAMP/bin/php/php5.6.10/bin/pear:/usr/bin:/bin:/usr/sbin:/sbin:
When I look for pear with $ locate bin/pear I get the same location as in the path:
/Applications/MAMP/bin/php/php5.6.10/bin/pear
Any idea what can be wrong?

Copied -- in essence -- from a comment:
Th $PATH environment variable should contain a list of directories to be searched for a command. Having the executable itself as part of the path doesn't help with resolving its location.

Related

Mac OSX (Apple Silicon) Homebrew installed but brew cmd not found

I have googled around the error I was experiencing but from what I could tell this issue is likely related to how the path in which Homebrew is saved for Big Sur/Apple Silicon is different than other Macbook approaches.
Following the instructions on the Homebrew page, I ran the cURL command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
However, after the operation successfully completed, there was a warning in terminal:
warning: bin/opt/ path does not exist
And when I attempted to run a brew doctor the command was not found.
It's clear there is a pathing issue, but how do I solve it
In this case, I discovered it was a combination of a PATH issue as well as the .zshrc file was missing from the ~/ directory
I was able to resolve the issue with these steps.
Navigate to cd /opt/homebrew/bin/
Run export PATH=$PATH:/opt/homebrew/bin
Navigate back to "home" with cd ~/
in this directory I found that there was no .zshrc file (:scream:)
So I created a file with touch .zshrc and then
ran this command: echo export PATH=$PATH:/opt/homebrew/bin >> .zshrc
And after running that command, I was able to successfully use the brew doctor and other related commands!

How to get VScode terminal to use packages installed on Mac terminal via composer

I installed composer using home brew on my Utilities terminal on my Mac.
When I try to use packages installed through composer, I get that it isn't installed. For example, I can run laravel new appname in the Mac terminal, but it won't let me run it in VScode terminal (using zsh). I get the error zsh: command not found: laravel.
Can someone help so that the VScode terminal uses the packages installed in my Mac terminal?
My /etc/paths file looks like this:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/melaniecarr/.composer/vendor/bin
You need to add the relevant directories to your PATH in ~/.zshenv. Try which laravel in the shell that works to see what directories you need to add. E.g.:
❯ which watch
/usr/local/bin/watch
❯ export PATH="/usr/local/bin:$PATH" # needs to be in ~/.zshenv to be permanent

Installing PHP_codesniffer with Pear and MAMP Pro on OSX

I've tried all kinds of fixes to get php_codesniffer working with OSX and Pear and am having no luck. The installation works, the scripts are there, but when I run, for example, phpcs -h, nothing happens.
I am doing the following to install and try to run:
chris#DEATHSTAR:~$ pear clear-cache
reading directory /var/folders/r5/3s2lsmc10zj07nw56xbx1k1m0000gn/T//pear/cache
14 cache entries cleared
chris#DEATHSTAR:~$ pear install php_codesniffer
Unknown remote channel: pear.phpunit.de
Did not download optional dependencies: channel://pear.phpunit.de/PHP_Timer, use --alldeps to download automatically
pear/PHP_CodeSniffer can optionally use package "channel://pear.phpunit.de/PHP_Timer"
downloading PHP_CodeSniffer-1.4.6.tgz ...
Starting to download PHP_CodeSniffer-1.4.6.tgz (402,882 bytes)
.................................................................................done: 402,882 bytes
install ok: channel://pear.php.net/PHP_CodeSniffer-1.4.6
chris#DEATHSTAR:~$ which phpcs
/Applications/MAMP/bin/php/php5.4.10/bin/phpcs
chris#DEATHSTAR:~$ phpcs -h
chris#DEATHSTAR:~$
The PHP directory is correct in Pear config:
chris#DEATHSTAR:~/.vim$ pear config-show | grep php_bin
PHP CLI/CGI binary php_bin /Applications/MAMP/bin/php/php5.4.10/bin/php
Not sure what else I can do to troubleshoot?
Possible related note: PHP Mass Detector does essentially the same thing...it installs correctly, but running it seemingly does nothing as well!
I think the phpcs binary file is not inside your $PATH. Use the follow steps to figure out if this is true:
Call the codesniffer on your command line with entering the full path:
$ /Applications/MAMP/bin/php/php5.4.10/bin/phpcs -h
If you get the help output then proceed with step 2. If not something else is broken in your setup.
Export this path to $PATH:
$ export PATH=$PATH:/Applications/MAMP/bin/php/php5.4.10/bin/phpcs
Call the CodeSniffer like you try before:
$ phpcs -h
To make this change permanent you need to insert the command from 2. into you .profile/.bashrc/.zshrc or whatever you use as a shell

PEAR included with MAMP: how to access via Terminal?

I'm trying to run a command that downloads a bit of software using PEAR installed with MAMP.
Here's the command I run in Terminal:
pear channel-discover pear.phpdoc.org
The Terminal responds with:
-bash: pear: command not found
Could someone please advise how to access PEAR that comes pre-installed with MAMP?
Path to MAMP on my Mac is /Applications/MAMP/
I do not use mamp but i think you can find the pear here:
/Applications/MAMP/bin/php5.3/bin/pear
you can simply add some alias to make it shorter, something like
alias mamppear="/Applications/MAMP/bin/php5.3/bin/pear"

PHPUnit installed but simply doing nothing

I am following along with the tutorials in 'Easy PHP Websites with Zend Framework' and wanted to install PHPUnit.
System: Mac OS x Lion, PHP running locally (Not MAMP)
Pear was installed and working fine, I upgraded it to the latest.
Installed PHPUnit using
sudo pear install phpunit/PHPUnit
terminal did some work and installed it without errors
The in my terminal I did
phpunit --version
this returns/does nothing as follows (Username removed)
Machine:~ Username$ phpunit --version
Machine:~ Username$ sudo phpunit --version
Machine:~ Username$
Was worried it some how did not install so I check for the PHPUnit files and they do exist under /usr/lib/php/phpunit
Also checked that the phpunit exe exists which it does under /usr/bin
edited .profile as well as .bash_profile to include the /usr/bin path to have
export PATH=/usr/bin:$PATH
then restarted terminal
running
echo $PATH
shows
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/Users/xxxxx/development/frameworks/ZendFramework-1.11.11/bin
php.ini includes is
include_path = ".:/usr/lib/php/pear:/Library/Server/Web/Data/Sites/ZendFramework-1.11.11/library"
Where xxxxx is my username on the Mac
even going into /usr/bin in terminal and using phpunit --version returns nothing
in case its relevant my PEAR config shows
Configuration (channel pear.php.net):
=====================================
...
...
PEAR executables directory bin_dir /usr/bin
PEAR documentation directory doc_dir /usr/lib/php/doc
PHP extension directory ext_dir /usr/lib/php/extensions/.....
PEAR directory php_dir /usr/lib/php
PEAR data directory data_dir /usr/lib/php/data
PHP CLI/CGI binary php_bin /usr/bin/php
php.ini location php_ini <not set>
....
....
PEAR Installer temp directory temp_dir /private/tmp/pear/temp
PEAR test directory test_dir /usr/lib/php/test
PEAR www files directory www_dir /usr/lib/php/htdocs
....
Also added the pear and phpunit directory to my php.ini includes path list.
Am at a loss as to why this does not want to work. Am sure its me and I have done something incorrectly....Any help appreciated.
Ok, solved this, finally after much reading and fiddling. Issue was with PEAR, not PHPUnit itself.
Found the issue by following the set up for PEAR onhttp://pear.php.net/manual/en/installation.checking.php
php.ini change from
.:/usr/lib/php/pear:/Library/Server/Web/Data/Sites/ZendFramework-1.11.11/library:/usr/lib/php/PHPUnit
to
.:/usr/lib/php/pear:/Library/Server/Web/Data/Sites/ZendFramework-1.11.11/library:/usr/lib/php
solved this issue immediately.
phpunit --version now works

Resources