Welcome Guest, Not a member yet? Register   Sign In
Is it possible to have subforder in Controlllers directory
#1

I am starting a project and wanted to put all admin controler in  a sub directory admin. I try it but

I receveive a message the Controller or its method is not found: App\Controllers\Admin::categ

I don't want to put all sources in only the same controller directory
Reply
#2

You need to reference it as App\Controllers\Admin\Admin, as it's an Admin controller inside an Admin folder.

PHP Code:
namespace App\Controllers\Admin
Reply
#3

(This post was last modified: 04-08-2020, 01:23 AM by kris2.)

(04-06-2020, 08:57 AM)jreklund Wrote: You need to reference it as App\Controllers\Admin\Admin, as it's an Admin controller inside an Admin folder.

PHP Code:
namespace App\Controllers\Admin

Thank you. I think something is still missing

Class 'App\Controllers\Admin\BaseController' not found

APPPATH/Controllers/Admin/Acticateg.php at line 2

Code:
1 <?php namespace App\Controllers\Admin;
2 class Acticateg extends BaseController {
Reply
#4

BaseController are in the \App\Controllers\BaseController and needs to have it's full reference or you need to specify use.

PHP Code:
<?php namespace App\Controllers\Admin;
class 
Acticateg extends \App\Controllers\BaseController 

PHP Code:
<?php namespace App\Controllers\Admin;

use \
App\Controllers\BaseController;

class 
Acticateg extends BaseController 
Reply
#5

I've got a couple of free articles about namespaces that will help clarify things for you, I think:

Primar: Namespaces and CI4
Going Deeper with Namespaces
Reply
#6

Thank you that works now. Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB