Mac osx Lion phpunit require(/usr/lib/php/PHPUnit/Autoload.php) - osx-lion

I am migrating to a new computer moving from snow leopard to lion at the same time. phpunit did not seem to make the migration, so I have reinstalled it. However the standard install with pear seems to not work with my home brew install of php. Here is the error:
phpunit
PHP Warning: require(/usr/lib/php/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43
Warning: require(/usr/lib/php/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43
PHP Fatal error: require(): Failed opening required '/usr/lib/php/PHPUnit/Autoload.php' (include_path='.:/Users/bimemployee/pear/share/pear:/usr/lib/php') in /usr/bin/phpunit on line 43
Fatal error: require(): Failed opening required '/usr/lib/php/PHPUnit/Autoload.php' (include_path='.:/Users/bimemployee/pear/share/pear:/usr/lib/php') in /usr/bin/phpunit on line 43
I have my computer setup with my main /etc/php.ini file as a symlink to the home brew php.ini file at /usr/local/etc/php.ini this contains my include path which seems to be working.
php -r 'foreach (explode(":", get_include_path()) as $path) echo $path . PHP_EOL;'
No log handling enabled - turning on stderr logging
Cannot find module (LM-SENSORS-MIB): At line 0 in (none)
.
/Users/bimemployee/pear/share/pear
/usr/lib/php
I am also setting up php to work with the homebrew version via the .bash_profile file.
export PATH="$(brew --prefix)/bin:$PATH"
which php
/usr/local/bin/php
which phpunit
/usr/bin/phpunit
Thanks for any help.
-Cory

Maybe you don't have the latest version or the full phpunit installation. You need to install all dependencies using --alldeps
So you should install phpunit like this:
pear channel-discover pear.symfony.com # for Yaml dependency
pear channel-discover pear.phpunit.de
pear install --alldeps phpunit/PHPUnit
This work for me ;)

The problem you having might be connected with your include_path, actual (real) php lib directory and with brew link command.
Brew installs php lib into Cellar directory and than links (brew link) all existing resources to /usr/local/lib/php (or /usr/lib/php - depending on your installation).
The problem is File.php and File/ appears in Cellar php lib after linking process (probably after pear update/upgrade). That means it will be not linked in /usr/local/lib/php.
To fix it you can simply brew unlink and brew link again.
Additionally it would be good to set your pear php_dir to /usr/local/lib/php. This way all new pear modules will be installed in correct destination without linking process. This makes nice separation between custom Pear modules and PHP lib itself.

You need to set your php include path in php.ini so that it includes the PEAR directory where PHPUnit lives.
include_path = ".:/Applications/MAMP/bin/php/php5.3.6/lib/php:"
You may need to search for Autoload.php using spotlight to find the right location.

Related

Problems running init as part of yii 2 install

I am installing yii 2 on a mac. I have mamp pro (3.0.7.3 latest) when i go to the command line and run.
php init i get a message saying
The mcrypt PHP extension is required by Yii2.
I checked the server using phpinfo() and it shows mcypt enabled. I checked the php.ini and it is listed and the file exists in the referenced directory.
any ideas anyone ??
This probably means that your php CLI (Command Line Interface) does not use the same php.ini than MAMP. You could use something like php -c /path/to/mamp/php.ini to be sure to use the same php.ini.
Or try the following command : php --ini, this will show you configuration file names, e.g. :
Configuration File (php.ini) Path: /path/to/php/conf
Loaded Configuration File: (none)
You could then make a symbolic link :
cd /path/to/php/conf
sudo ln -s /path/to/mamp/php.ini php.ini

Installing mod_perl-2.0.7 on Apache httpd-2.4.2

I am having an infuriating time trying to get an install of apache with perl. I am following the instructions on the mod_perl site located here: http://perl.apache.org/docs/2.0/user/install/install.html
I get as far as the part where it asks me to run this command, but I get an error:
$ perl Makefile.PL MP_APXS=/usr/local/httpd/prefork/bin/apxs
Reading Makefile.PL args from #ARGV
MP_APXS = /usr/local/httpd/prefork/bin/apxs
no conflicting prior mod_perl version found - good.
Configuring Apache/2.4.2 mod_perl/2.0.7 Perl/v5.12.3
[ error] Can't find apr include/ directory,
[ error] use MP_APR_CONFIG=/path/to/apr-config
I ran the commands they suggested for installing apache to install my apache:
$ ./configure --prefix=$HOME/httpd/prefork --with-mpm=prefork
$ make && make install
But I am not sure where this apr-config thing is supposed to be as it doesn't appear to be anywhere in my apache2 folder.
If it might be an issue, I am using Mac OS X 10.7.3. I know an apache server comes with Mac OS X, but I need to do this install on a different computer from the ground up, so I have to start this whole install from the ground up on my computer.
Thanks ahead of time for any help you can provide.
When mod_perl 2.0.8 comes out, I hope that it gets finally httpd 2.4 support, because the current versions surely don't have.
When you fix your initial problems, you will eventually get stuck at ‘conn_rec’ has no member named ‘remote_ip’. Delete httpd 2.4 and use 2.2 meanwhile.
You need to include the path to binary executable file apr-1-config. Run the below command
perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs MP_APR_CONFIG=/usr/local/apr/bin/apr-1-config
It worked for me..Hope the same for you too.
On Lion here, my APR include directory seems to be /usr/include/apr-1, but it already came with mod_perl.
$ find / -name apr*
/usr/include/apr-1
...
$ find / -name mod_perl.so
/usr/libexec/apache2/mod_perl.so
If you have the .so already you should be able to just add in your config file:
LoadModule perl_module libexec/apache2/mod_perl.so

Install GD Library on RedHat machine for twiki

My ultimate goal is to run a twiki website for my research group.
I have space on RedHat server that is running Apache, etc., but upon which I do not have root access. Since I cannot install perl modules with the current permissions, I've decided to manually install a local version of perl. Got that working no problem. The following modules are required to get twiki to work:
FreezeThaw - http://search.cpan.org/~ilyaz/FreezeThaw
CGI::Session - http://search.cpan.org/~markstos/CGI-Session
Error - http://search.cpan.org/~shlomif/Error
GD - http://search.cpan.org/~lds/GD
HTML::Tree - http://search.cpan.org/~petek/HTML-Tree
Time-modules - http://search.cpan.org/~muir/Time-modules
I have installed FreezeThaw, CGI, Error, and it fails on GD with the following error:
UNRECOVERABLE ERROR Could not find gdlib-config in the search path.
Please install libgd 2.0.28 or higher. If you want to try to
compile anyway, please rerun this script with the option --ignore_missing_gd.
In searching for how to get around this newest obstacle, I found a previous SO question: How to install GD library with Strawberry Perl asked about installing this and the top answer suggested manually compiling gdlib. You'll note, however, that that link is broken. The base site: http://www.libgd.org/ is basically down saying to go to the project's bitbucket page.
So I got the tarball from that page and am trying to install it. The following problems occur when I follow the instructions included. README.TXT says: "If the sources have been fetched from CVS, run bootstrap.sh [options]."
Running bootstrap.sh yields:
configure.ac:64: warning: macro `AM_ICONV' not found in library
configure.ac:10: required directory ./config does not exist cp: cannot
create regular file `config/config.guess': No such file or directory
configure.ac:11: installing `config/config.guess' configure.ac:11:
error while copying cp: cannot create regular file
`config/config.sub': No such file or directory configure.ac:11:
installing `config/config.sub' configure.ac:11: error while
copying cp: cannot create regular file `config/install-sh': No such
file or directory configure.ac:28: installing `config/install-sh'
configure.ac:28: error while copying cp: cannot create regular
file `config/missing': No such file or directory configure.ac:28:
installing `config/missing' configure.ac:28: error while copying
configure.ac:577: required file `config/Makefile.in' not found
configure.ac:577: required file `config/gdlib-config.in' not found
configure.ac:577: required file `test/Makefile.in' not found
Makefile.am:14: Libtool library used but `LIBTOOL' is undefined
Makefile.am:14: The usual way to define `LIBTOOL' is to add
AC_PROG_LIBTOOL' Makefile.am:14: to configure.ac' and run
aclocal' and autoconf' again. Makefile.am:14: If `AC_PROG_LIBTOOL'
is in `configure.ac', make sure Makefile.am:14: its definition is in
aclocal's search path. cp: cannot create regular file
`config/depcomp': No such file or directory Makefile.am: installing
`config/depcomp' Makefile.am: error while copying Failed
And it says I should also install the following 3rd party libraries:
zlib, available from http://www.gzip.org/zlib/
Data compression library
libpng, available from http://www.libpng.org/pub/png/
Portable Network Graphics library; requires zlib
FreeType 2.x, available from http://www.freetype.org/
Free, high-quality, and portable font engine
JPEG library, available from http://www.ijg.org/
Portable JPEG compression/decompression library
XPM, available from http://koala.ilog.fr/lehors/xpm.html
X Pixmap library
Which I am ignoring for now.
Switching to the generic instructions it says follow the advice in the INSTALL file; which says: "cd to the directory containing the package's source code and type ./configure to configure the package for your system." Which flat does not work: I've cd'ed into every directory of the tarball and running that command does nothing.
So, trying to install twiki required me to install perl, which required me to install the perl modules: FreezeThaw, CGI, Error, HTML, Time-modules, and GD -- which itself required me to install gdlib -- which further suggested I install zlib, libpng, FreeType 2.x, JPEG library, and XPM. And of course, I'm stuck at the installing gdlib stage.
My question is: what other process can possibly demean humanity to such a level? I cannot fathom the depths of cruelty that lay ahead of me as I dive ever deeper into this misery onion. Should I just end it all? Can meaning be brought from this madness? Will the sun come up tomorrow, and if so, does it even matter?
But seriously, any suggestions on what to do differently/better would be much appreciated -- I can't remember what a child's laughter sounds like anymore.
Install the package gd-devel, it contains /usr/bin/gdlib-config.
This should work:
sudo apt-get -y install libgd2-xpm-dev build-essential

How to install XML::Parser without expat-devel?

XML::Parser fails to build on a quite fresh 64-bit Debian box. After issuing cpan XML::Parser, cpan fails with lots of errors about Expat.c and Expat.xs:
[...]
Expat.xs:2182: error: ‘CallbackVector’ has no member named ‘skip_until’
Expat.c: In function ‘XS_XML__Parser__Expat_Do_External_Parse’:
Expat.c:2904: error: ‘XML_Parser’ undeclared (first use in this function)
Expat.c:2904: error: expected ‘;’ before ‘parser’
Expat.xs:2194: error: ‘parser’ undeclared (first use in this function)
make[1]: *** [Expat.o] Error 1
make[1]: Leaving directory `/root/.cpan/build/XML-Parser-2.41-rpV6ok/Expat'
make: *** [subdirs] Error 2
TODDR/XML-Parser-2.41.tar.gz
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
Message at the start of the output explains that expat-devel is needed for building.
Expat must be installed prior to building XML::Parser and I can't find
it in the standard library directories. Install 'expat-devel' package with your
OS package manager. See 'README'.
But expat-devel is not in Debian repository.
Is it possible to get over this without need to build/install expat from source?
The package you want to install is named libexpat1-dev. You could also just install libxml-parser-perl via apt-get. Or if you really want to install via CPAN try installing the Debian packages dependencies first via apt-get build-dep libxml-parser-perl.
libexpat1-dev contains both libexpat and expat.h, which are both mentioned in the message as well:
If expat is installed, but in a non-standard directory, then use the
following options to Makefile.PL:
EXPATLIBPATH=... To set the directory in which to find libexpat
EXPATINCPATH=... To set the directory in which to find expat.h
Installing libexpat1-dev seems to solve the problem:
$ aptitude install libexpat1-dev
There is always the manual method - to build/install expat from source.
(This example shows installing to an alternative location for XAMPP | LAMPP)
Download from:
http://sourceforge.net/projects/expat/files/expat/
tar zxf /[where-ever]/expat-2.1.0.tar.gz -C /tmp
cd /tmp/expat-2.1.0
/opt/lampp/bin/perl ./configure --prefix=/opt/lampp LDFLAGS=-L/opt/lampp/lib
make
make install
http://search.cpan.org - search for and download - XML::Parser
tar zxf /[where-ever]/XML-Parser-2.41.tar.gz -C /tmp
cd /tmp/XML-Parser-2.41
/opt/lampp/bin/perl ./Makefile.PL EXPATLIBPATH=/opt/lampp/lib EXPATINCPATH=/opt/lampp/include
make
make test
make install
Work like a charm in Ubuntu 15.04. The only thing that I need is install Perl XML Parser with:
sudo apt-get install libxml-parser-perl
And following the instructions here, I was able to import successfully all my ratings into Rhythmbox. Now, the only work that I need to do is create again the smart play lists, that is nothing compared with my entire libray ratings.
Today I had the same issue wanting to complile the new GIMP 2.9.4 beta on OSX 10.8 and the aid of homebrew.
First install perl
brew install perl
Then the XML::Parser module by going into the perl shell with
perl -MCPAN -e shell
And inside the shell install XML::Parser by typing
install XML::Parser
Exit shell
exit
Now, verify it has been installed successfully. If everything is ok, you will not see an error.
perl -e "require XML::Parser"
If the ./configure still fails missing XML::Parser, then intltools is not using the perl you have installed. Looking at the script tells me it does the test with $INTLTOOL_PERL -e "require XML::Parser". Trying a echo $INTLTOOL_PERL gave out nothing, so the magic is to set it with
export $INTLTOOL_PERL=perl
Now run ./configure again.
None of the above methods worked for me. I had the right environment variables setup but they were somehow not picked up by cpanm that I use to install perl modules. Expat was also installed.
Here is what I did to overcome the same problem that OP is reporting.
This is very close to what #LadyBuzz suggested.
Download the XML::Parser from cpan.org
Extract the tarball into directory and descend to it.
Open the Makefile.pl and edit the first lines to actually have the absolute paths to both: EXPATLIBPATH and EXPATINCPATH
Save the Makefile.pl, go up one level and create a new tarball with the Makefile.pl that you just edited.
Execute cpanm on the newly created tarball.
This resulted in successful installation of the module.

failed to open stream: No such file or directory in /usr/bin/phpunit

while trying to do Unit Testing with Zend Framework I executed the command
sudo phpunit --configuration phpunit.xml
and got this error
PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38
Sounds like your install of phpunit did not contain all the dependent packages, like PHP_CodeCoverage.
Perhaps try something like:
sudo pear install --alldeps phpunit/PHPUnit
More details at PHPUnit installation page of the docs.
Maybe your pear is too old.
See if the following tip can solve the issue:
http://www.giocc.com/installing-phpunit-on-ubuntu-11-04-natty-narwhal.html