mrmrn mrmrn - 1 year ago 58
PHP Question

Class 'App\Http\Controllers\Illuminate\Container\Container' not found

I want to parse an XML.
I writed this ResultController

namespace App\Http\Controllers;

use Auth;
use \App\User;
use Illuminate\Http\Request;
use XmlParser;
use Illuminate\Container\Container;
use Orchestra\Parser\Xml\Document;
use Orchestra\Parser\Xml\Reader;

class ResultController extends Controller

public function getResults()

$xml = XmlParser::load('');
$app = new Illuminate\Container\Container;
$document = new Orchestra\Parser\Xml\Document($app);
$reader = new Orchestra\Parser\Xml\Reader($document);

$xml = $reader->load('');
$user = $xml->parse([
'users' => ['uses' => 'Team[Team_Id,Name]'],

// dd($xml);
return view ('');


I used use Illuminate\Container\Container; at top of the controller but it gaves me this error:

FatalErrorException in ResultController.php line 13: Class
'Illuminate\Container\Container\Controller' not found.

I cant understand what is wrong with it?

Answer Source

If you've used use keyword above -

use Illuminate\Container\Container;
use Orchestra\Parser\Xml\Document as OrchestraDocument;
use Orchestra\Parser\Xml\Reader as OrchestraReader;

you should use it inside method as (updated):

$app = new Container;
$document = new OrchestraDocument($app);
$reader = new OrchestraReader($document);

As you've used new Illuminate\Container\Container the php would find your container as - App\Http\Controllers\Illuminate\Container\Container, which isn't the correct path, the use keyword helps php to recognize the namespace of class Container

For more info see PHP Namespacing Docs

Hope this helps!