Awais Qarni Awais Qarni - 1 year ago 110
PHP Question

Using packages in Laravel 5.1

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

section of
'XmlParser' => Orchestra\Parser\Xml\Facade::class

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
if some one has used it.

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download