如何解决ReflectionException类orchestra.parser.xml不存在

I am trying to create an xml file using Orchestral/parser

https://github.com/orchestral/parser

I correctly installed it and called it like this in my Controller:

use Orchestra\Parser\Xml\Facade as XmlParser;

...

class Product extends Controller
{    
    public function createProduct()
   {
        $xml    = XmlParser::load("test.xml");
        $xmlR = $xml->parse([
            'id' => ['uses' => 'xmlR.id'],
        ]);
   }
}

But I get following error message:

ReflectionException in Container.php line 741: Class orchestra.parser.xml does not exist

Thus I do not really understand what load means(in my case load("test.xml").

Did you try to refresh the autoload with command: composer dump-autoload

Your error clearly points that you did not set up the package in your config/app.php file (by listing the provider for the Orchestral XML Parser).

To resolve it, do add Orchestra\Parser\XmlServiceProvider::class to the list of providers in your config/app.php file as illustrated below:

'providers' => [

// Other Laravel service providers

Orchestra\Parser\XmlServiceProvider::class,

],

clearing the cache fixed my problem:

php artisan cache:clear
php artisan config:cache