Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Orchestra Xml Parser through Laravel IoC Container

I am using laravel 5.1. I want to use XML parser and I have searched and found Orchestra as mostly being used. So I have gone thorough all the steps given at documentation to install and configure. I have added Orchestra\Parser\XmlServiceProvider::class in providers section of config/app.php and 'XmlParser' => Orchestra\Parser\Xml\Facade::class in aliases section.

Now in my controller, I have added its name space like use Orchestra\Parser\Xml\Facade; at the top of my controller. But when i try to use its function in my action, like

$xml = XmlParser::load($xml_document);

It generates error stating,

Class 'App\Http\Controllers\XmlParser' not found

So I want to know is there any other way in Laravel 5.1 to use the packages and I am doing some thing wrong with Orchestra if some one has used it.

like image 453
Awais Qarni Avatar asked Dec 05 '22 02:12

Awais Qarni


1 Answers

Since the documentation already describe registration of the facade alias:

'XmlParser' => Orchestra\Parser\Xml\Facade::class,

You can either use \XmlParser::load(), or import the alias.

use XmlParser;

or import the full namespace.

use Orchestra\Parser\Xml\Facade as XmlParser;
like image 62
crynobone Avatar answered Dec 08 '22 04:12

crynobone