: This article mainly introduces the causes and solutions of phpunit installation errors. if you are interested in PHP tutorials, please refer to them. Official Guide
Unfortunately, phpunit is not in the ArchLinux repository.
Therefore, download and install the SDK. Follow the official guidelines:
wget https://phar.phpunit.de/phpunit.pharchmod +x phpunit.pharsudo mv phpunit.phar /usr/local/bin/phpunitphpunit --version
The following error is returned:
PHP Warning: realpath(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 3PHP Fatal error: Class 'Phar' not found in /usr/local/bin/phpunit on line 714
Enable phar extension
Solution firstFatal error: Class 'Phar' not found
.
ls /usr/lib/php/modules
If phar. so is found, it indicates that the Phar extension has been installed. Is there no Enable for the extension?
Open/etc/php/php.ini
Searchphar
And foundextension=phar.so
Commented out. Remove;
, Save php. ini and run it againphpunit --version
.
PHP Warning: realpath(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 3PHP Warning: Phar::mapPhar(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 714
Fatal error
Solved, but the warning is still in progress, and phpunit is not running properly.
Php file access protection mechanism
Google, found here there is an explanation: http://www.templatemonster.com/help/open_basedir-restriction-in-effect-filex-is-not-within-the-allowed-paths-y.html
PHP open_basedir protection tweak is a Safe Mode security measure that prevents users from opening files or scripts located outside of their home directory with PHP, unless the folder has specifically excluded. PHP open_basedir setting if enabled, will ensure that all file operations to be limited to files under certain directory, and thus prevent php scripts for a special user from accessing files in unauthorized user's account. when a script tries to open a file with, for example, fopen () or gzopen (), the location of the file is checked. when the file is outside the specified or permissible directory-tree, PHP will refuse to open it and the following errors may occur :...
In php. iniopen_basedir
Is the setting for php to ensure secure file access. If this option is assigned, all file operations are limited to a specific directory, which prevents a user from using php scripts to read unauthorized content. When you want to passfopen
Orgzopen
When opening a file, if the file is no longer in the allowed directory, the above warning will appear.
The directories that can be accessed from the warning information include/srv/http/:/home/:/tmp/:/usr/share/pear/
, Exactly~/bin
That is, in the PATH variable, it is also a directory that can be read by php scripts.
mv /usr/local/bin/phpunit ~/bin
Run Againphpunit --version
To get the correct result:
PHPUnit 4.5.0 by Sebastian Bergmann and contributors.
Phpunit is installed successfully!
The above describes the cause and solution of phpunit installation errors, including some content, and hope to be helpful to friends who are interested in PHP tutorials.