PhpStrom + Composer + PHPUnit + XAMPP
Question
Root composer.json requires monolog/monolog, it could not be found in any version,…..
1.1 全局模式
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
composer config -g --unset repos.packagist
1.2 仅当前项目配置
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
composer config --unset repos.packagist
1.3 配置完成后调试
composer -vvv require alibabacloud/sdk
PHPUnit Cannot open file “XXXTest”
PHPUnit 9 isn’t supported in PhpStorm 2018.3.3. or 2019.3.3. Please use PHPUnit 8.*, use EAP build 2020.1 release .
edit composer.json
initial
"require-dev": {"phpunit/phpunit": "9.5.8"}
finally
"require-dev": {"phpunit/phpunit": "8.*"}
homebrew install fail
source /Users/willson/.zprofile
Xdebug: [Config] The setting ‘xdebug.remote_enable’ has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
config php.ini
xdebug.client_host = 127.0.0.1
xdebug.client_port = 9000
xdebug.mode = debug`
config GD
windows
Root composer.json requires php ~8.0.8 but your php version (7.3.11) does not satisfy that requirement.
composer install –ignore-platform-reqs or
"require": {"php": "^7.3|^8.0",.....},
webserver xdebug
PhpStrom
install xdebug
matching debug-version
copy phpinfo() information
Download xdebug-x.x.x.tgz
Install the pre-requisites for compiling PHP extensions.On your Mac, we only support installations with ‘homebrew’, and
brew install php && brew install autoconf
should pull in the right packages.Unpack the downloaded file with
tar -xvzf xdebug-x.x.x.tgz
Run: cd xdebug-x.x.x
Run:
phpize
(See the FAQ if you don’t havephpize
).As part of its output it should show:
Configuring for: ... Zend Module Api No: 20200930 Zend Extension Api No: 420200930
If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
check xdebug-x.x.x path
for example: cd /xxxxx/xxxxx/Documents/xdebug-x.x.x/xdebug-x.x.x
Run:
./configure
Run:
make
Run
cp modules/xdebug.so /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20200930
Update
/Applications/XAMPP/xamppfiles/etc/php.ini
and add the line:zend_extension = xdebug
Restart the Apache Webserver
conig webserver xdebug
配置php.ini
[xdebug] zend_extension = xdebug xdebug.idekey = PHPSTROM
install steps
XAMPP
Composer
config PHP version
install composer
Global install composer
sudo mv composer.phar /usr/local/bin/composer
创建composer.json
切换到当前项目地址执行命令
curl -sS https://getcomposer.org/installer | php
orphp composer.phar install
php composer.phar init
生成 composer.json特殊注意如下图
{ "name": "test/development", "type": "project", "autoload": { "psr-4": { "test\\Development\\": "src/" } }, "authors": [ { "name": "***********", "email": "**********" } ], "require": { "php": "~7.2", }, "require-dev": { "phpunit/phpunit": "9.5.8" "monolog/monolog": "2.0.*" } }
search 第三方类库
php composer.phar search ***
PHPUnit
config php.ini
memory_limit=-1
error_reporting=-1
log_errors_max_len=0
zend.assertions=1
assert.exception=1
xdebug.show_exception_trace=0
install PHPUnit
composer install