Back

Using $rss = new DOMDocument(); in function of a Controller


Hi,

i would like to include a small RSS reader into a function of a controller:

class RSSController extends Controller

{

public function logger()

{

$rss = new DOMDocument();
$rss->load('http://www.domain.com/feed.rss');

}

}

This produces the following error message:

Fatal error: Class 'App\Http\Controllers\DOMDocument' not found in /is/htdocs/.../www/domain/laravel/app/Http/Controllers/RSSController.php on line 51

Any ideas how to solve this?

Thanks! Sharping

kuberjsr replied 10 months ago

You must prefix the class name with the global namespace prefix ''

Your new class be like :

class RSSController extends Controller

{

public function logger()

{

$rss = new \DOMDocument();

$rss->load('http://www.domain.com/feed.rss');

}

}


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us