phpcs - class must be in a namespace of at least one level - how to fix?

Dariux picture Dariux · Dec 9, 2014 · Viewed 10k times · Source

I am using laravel 4.2.

Lets say there is such class:

class BShopsController extends ShopsController

To fix this, I try to use name space lets say this:

namespace app\controllers;

and then it does not find ShopsController

so I add

use \ShopsController;

Then I get error:

Class BShopsController does not exist

What namespace should I use first of all so it would not break anything?

Edit:

BShopsController and ShopsController are in folder Shops

Answer

Shhetri picture Shhetri · Dec 9, 2014

As your files are inside the Shops folder and I believe that the Shops folder is inside the app folder you should namespace your class the following way.

<?php namespace Shops;

class BShopsController extends ShopsController{}

Similarly,

<?php namespace Shops;

    class ShopsController{}