Phpunit installation error cause and solution

Source: Internet
Author: User
: 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.iniSearchpharAnd foundextension=phar.soCommented 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 errorSolved, 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_basedirIs 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 passfopenOrgzopenWhen 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~/binThat 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 --versionTo 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.