laravel执行phpunit报错:Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable

laravel执行phpunit报错:

Illuminate\Contracts\Container\BindingResolutionException: Target 
[Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable

出现这个错误可能是本地的phpunit版本和项目的phpunit版本不一致导致的,因此方法有二:

  • 使用项目的phpunit,即将phpunit改成vendor/bin/phpunit
  • 升级项目的phpunit,或者降级本机phpunit

为了在postman中使用xdebug调试php代码,在URL后面加上这个?XDEBUG_SESSION_START=PHPSTORM,经测试只要添加一次,之后的请求可以不用添加(除非重新打开postman)

更新:可能有必要关闭fpm,以为xdebug和fpm用的端口可能都是9000,导致冲突。

Apache路由重写

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>