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

I am using laravel 4.2.

Suppose that there is such a class:

class BShopsController extends ShopsController 

To fix this, I'm trying to use a namespace, let's say this:

 namespace app\controllers; 

and then does not find ShopsController

so i add

 use \ShopsController; 

Then I get the error:

BShopsController class does not exist

What namespace should you use first so that it doesn't break anything?

Edit:

BShopsController and ShopsController are in the Stores folder

+1
php namespaces laravel-4 codesniffer
Dec 09 '14 at 8:27
source share
2 answers

So Using Shhetri and Using Namespaces in Laravel 4

I did like this:

 namespace App\Controllers\Shops; class BShopsController extends ShopsController{} 

Also in routes.php you need to change to this:

 Route::controller('shops', 'App\Controllers\Shops\ShopsController'); 

And where is the call method () - should also use the namespace.

Also need to run

 composer dump-autoload -o 

otherwise there were errors.

Also in ShopsContrller you need:

 use \App\Controllers\BaseController; 

Because the store controller was in a different namespace than BaseController, and cannot find it. But extends from BaseController, so it needs to.

+3
Jan 09 '15 at 7:10
source share
— -

Since your files are inside the Stores folder, and I believe the Stores folder is inside the application folder, you should skip the space in your class as follows.

 <?php namespace Shops; class BShopsController extends ShopsController{} 

Similarly

 <?php namespace Shops; class ShopsController{} 
+4
Dec 09 '14 at 12:12
source share



All Articles