成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

phpunit 安裝

microelec / 1762人閱讀

摘要:所以使用下載安裝的方式。解決了,但警告還在,而且沒有正常運(yùn)行。從警告信息發(fā)現(xiàn)可以訪問的目錄包括,剛好即在變量中,也屬于可以被腳本讀取的目錄,于是再運(yùn)行,得到正確結(jié)果安裝成功

官方指引

很遺憾, phpunit還沒有在ArchLinux的倉庫里。

所以使用下載安裝的方式。按照官方的指引:

wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version

結(jié)果得到下面的錯誤:

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 3
PHP Fatal error:  Class "Phar" not found in /usr/local/bin/phpunit on line 714
啟用phar擴(kuò)展

先解決Fatal error: Class "Phar" not found。

ls /usr/lib/php/modules

發(fā)現(xiàn)有 phar.so,說明Phar的擴(kuò)展已經(jīng)安裝,那么是不是該擴(kuò)展沒有Enable呢?
打開 /etc/php/php.ini搜索 phar,果然發(fā)現(xiàn) extension=phar.so被注釋掉了。去掉該行前面的 ;,保存php.ini,再次運(yùn)行 phpunit --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 3
PHP 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解決了,但警告還在,而且phpunit沒有正常運(yùn)行。

php對文件訪問的保護(hù)機(jī)制

google之,發(fā)現(xiàn)這里有解釋: 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 particular 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: ...

意思是說:php.ini中的open_basedir是php為保證安全進(jìn)行文件訪問的設(shè)置。如果該選項(xiàng)被賦值,所有的文件操作將限定在特定的目錄里,這樣可以防止某個用戶使用php腳本讀取未授權(quán)的內(nèi)容。當(dāng)你想通過fopengzopen打開一個文件時,如果該文件的位置不再被允許的目錄下面,就會出現(xiàn)上述的警告信息。

從警告信息發(fā)現(xiàn)可以訪問的目錄包括 /srv/http/:/home/:/tmp/:/usr/share/pear/,剛好 ~/bin即在PATH變量中,也屬于可以被php腳本讀取的目錄,于是

mv /usr/local/bin/phpunit ~/bin

再運(yùn)行phpunit --version,得到正確結(jié)果:

PHPUnit 4.5.0 by Sebastian Bergmann and contributors.

phpunit安裝成功!

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/20938.html

相關(guān)文章

  • phpUnit 安裝,實(shí)例和簡單部署

    背景:一個小腳本,保證穩(wěn)定為主;所以試用了下phpunit,快捷方便 phpunit 的安裝 phpunit是一個輕量級的php單元測試框架,通過pear安裝安裝過程 wget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar sudo mv phpunit.phar /usr/local/bin/phpunit phpunit ...

    617035918 評論0 收藏0
  • PHP單元測試框架PHPUnit的使用

    摘要:以前在學(xué)習(xí)開發(fā)時有專門寫過的單元測試的文章,開發(fā)學(xué)習(xí)之單元測試,今天再總結(jié)下怎么在中使用單元測試。是一個用編程語言開發(fā)的開源軟件,是一個單元測試框架。單元測試框架經(jīng)常會包含每個測試的報告,以及給出你已經(jīng)覆蓋到的代碼覆蓋率。 以前在學(xué)習(xí)IOS開發(fā)時有專門寫過Objective-C的單元測試的文章,IOS開發(fā)學(xué)習(xí)之單元測試,今天再總結(jié)下怎么在PHP中使用單元測試。 一、前言 在這篇文章中,...

    Bryan 評論0 收藏0
  • PHP 單元測試

    摘要:上面的規(guī)定是必須遵守的,如果代碼沒有遵守規(guī)定不會把他當(dāng)做單元測試代碼。每個單元測試類以被測試的類名開頭。每個單元測試函數(shù)應(yīng)該為被測試函數(shù)名結(jié)尾。函數(shù)可能在測試環(huán)境不可執(zhí)行,那么無法獲取的執(zhí)行結(jié)果,從而無法對進(jìn)行單元測試。 本文首發(fā)于 https://jaychen.cc/article/34作者 Jaychen showImg(https://segmentfault.com/img/...

    娣辯孩 評論0 收藏0
  • phpunit入門

    摘要:安裝安裝教程參考說明下安裝那個盤符無所謂下如果不定義全局變量,可以進(jìn)入所在目錄才能執(zhí)行,例如當(dāng)然配環(huán)境變量,全局配置操作更方便一點(diǎn)全局配置,配置環(huán)境變量的路徑是建立外包覆批處理腳本最后得到官方教程里面第五步的所在路徑配置配置參考例如核心 安裝 安裝教程參考 說明 windows下安裝那個盤符無所謂 windows下如果不定義全局變量,可以進(jìn)入phpunit.phar所在目錄才能執(zhí)行...

    ls0609 評論0 收藏0
  • Laravel 測試: PHPUnit 入門教程

    摘要:介紹是最古老和最著名的單元測試包之一。它主要用于單元測試,這意味著可以用盡可能小的組件測試代碼,但是它也非常靈活,可以用于很多不僅僅是單元測試。這時,的測試助手可以使這些測試像單元測試簡單組件一樣容易。新的測試代碼如下注意到,在我們新建的 showImg(https://segmentfault.com/img/remote/1460000018355157?w=1440&h=585)...

    張憲坤 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<