Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laracoft's avatar
Level 27

`$enablesPackageDiscoveries` and `ignorePackageDiscoveriesFrom` don't seem to work

https://packages.tools/testbench/the-basic#package-auto-discovery

I have these 2 specified in my testcase, but still, the *ServiceProvider.php of a package that exists in my package's vendor does not get discovered.

Running the test, I keep getting the exception below

(which basically means the example-package singleton was not registered, because the entire service provider was not discovered)

Target class [example-package] does not exist.

  at vendor/laravel/framework/src/Illuminate/Container/Container.php:912
    908▕             return $concrete($this, $this->getLastParameterOverride());
    909▕         }
    910▕ 
    911▕         try {
  ➜ 912▕             $reflector = new ReflectionClass($concrete);
    913▕         } catch (ReflectionException $e) {
    914▕             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    915▕         }
    916▕ 

      +9 vendor frames 
  10  tests/Feature/ExampleTest.php:25


  Tests:    1 failed, 4 pending (0 assertions)
  Duration: 0.20s
0 likes
1 reply
laracoft's avatar
laracoft
OP
Best Answer
Level 27

For this mechanism to work, there must be a package:discover command in the package's composer.json, which earlier versions of testbench did not add

 "scripts": {
        "post-autoload-dump": [
            "@php vendor/bin/testbench package:discover"
        ]
    },

Please or to participate in this conversation.