Leon
Leon

Reputation: 1292

Error while loading Laravel Application

I am new to Laravel framework and after trying to start an application I am receiving this error with this stacktrace:

[2015-12-16 10:29:20] local.ERROR: exception 'ErrorException' with message 'The use statement with non-compound name 'DB' has no effect' in /Users/username/data/product/app/controllers/CampaignsController.php:3

This is how the Controller looks like in the beginning:

<?php

use \DB;
use \Auth;
use \Validator;
use \Event;
........

What am I missing here? Is it because i need to install some plugin for Laravel to work?

Upvotes: 0

Views: 84

Answers (1)

Kane Cohen
Kane Cohen

Reputation: 1800

You are not located within the namespace, so you can not execute use statements.

For example, if you're in a controller you might want to add following namespace at the top of the file:

<?php
namespace App\Http\Controllers;

use \DB;
...

Upvotes: 1

Related Questions