phplaravel-5phpspec

Laravel phpspec cannot be autoloaded


I am trying to setup phpspec in a Laravel project.

I have installed phpspec properly and am running phpspec inside my project without any trouble.

My composer.json file has the following relevant lines:

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "Acme\\": "app/Acme"
    }
},

My phpspec.yml:

suites:
  app_suite:
    namespace: Acme
    src_path: app
    spec_path: app
    spec_prefix: spec

Executing phpspec describe Acme/Foo created app\spec\Acme\FooSpec.php file. Executing phpspec run created app\Acme\Foo.php

But I am getting the following error when I run "phpspec run" -

The type Acme\Foo was generated but could not be loaded. Do you need to configure an autoloader?

Everything is fine, except for the auto-loading error. How can I solve the issue?


Solution

  • try

    composer dump-autoload
    

    It just regenerates the list of all classes that need to be included, when you have a new class inside your project