CodeIgniter Forums
Sub Directory on Controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Sub Directory on Controller (/showthread.php?tid=73262)

Pages: 1 2


RE: Sub Directory on Controller - MGatner - 09-24-2019

@andybiancoblu Are you getting an error message? E.g. 404 Not Found.

I don't *think* it would matter but you should try uppercase on your namespace: `App\Controllers\Dashboard`

Also make sure auto-routing is enabled (should be if you didn't change anything) in **app/Config/Routes.php**


RE: Sub Directory on Controller - andybiancoblu - 09-24-2019

(09-24-2019, 08:34 AM)MGatner Wrote: @andybiancoblu Are you getting an error message? E.g. 404 Not Found.

I don't *think* it would matter but you should try uppercase on your namespace: `App\Controllers\Dashboard`

Also make sure auto-routing is enabled (should be if you didn't change anything) in **app/Config/Routes.php**

Hi @MGatner,
yeah, I'm getting 404 error.
The only way to make it work was to add a route through $routes->add... Mapping subdir, controller and method, but I don't think that's the way of doing stuffs in CI4.
I'm running CI4 rc1 on a docker container, filesystem permissions are ok.
app/Config/Routes.php was modified only to set a default controller (which didn't work). To get it work i modified $routes->get('/', 'Class::method')

I'm trying right now to change to uppercase namespace. I did it like that cause I saw the guy who started the post that didn't use uppercase for namespacing the subdir.

Thanks a lot for the reply, I'm going to update you soon.

Andy


RE: Sub Directory on Controller - andybiancoblu - 09-24-2019

(09-24-2019, 09:29 AM)andybiancoblu Wrote:
(09-24-2019, 08:34 AM)MGatner Wrote: @andybiancoblu Are you getting an error message? E.g. 404 Not Found.

I don't *think* it would matter but you should try uppercase on your namespace: `App\Controllers\Dashboard`

Also make sure auto-routing is enabled (should be if you didn't change anything) in **app/Config/Routes.php**

Hi @MGatner,
yeah, I'm getting 404 error.
The only way to make it work was to add a route through $routes->add... Mapping subdir, controller and method, but I don't think that's the way of doing stuffs in CI4.
I'm running CI4 rc1 on a docker container, filesystem permissions are ok.
app/Config/Routes.php was modified only to set a default controller (which didn't work). To get it work i modified $routes->get('/', 'Class::method')

I'm trying right now to change to uppercase namespace. I did it like that cause I saw the guy who started the post that didn't use uppercase for namespacing the subdir
Ho again.
Tried ti uppercase namespace in my classe. No effect.


RE: Sub Directory on Controller - InsiteFX - 09-25-2019

If you change the namespace to all first capital letters you need to also change the
directory name to first letter capital.


RE: Sub Directory on Controller - andybiancoblu - 09-25-2019

Hi everyone.
Tried capital letters on folder and namespace.
Still not working. Any suggestion?


RE: Sub Directory on Controller - andybiancoblu - 09-25-2019

(09-24-2019, 08:34 AM)MGatner Wrote: @andybiancoblu Are you getting an error message? E.g. 404 Not Found.

I don't *think* it would matter but you should try uppercase on your namespace: `App\Controllers\Dashboard`

Also make sure auto-routing is enabled (should be if you didn't change anything) in **app/Config/Routes.php**

(09-25-2019, 02:47 AM)InsiteFX Wrote: If you change the namespace to all first capital letters you need to also change the
directory name to first letter capital.
Hi again.
This is my 404:

404 - File Not Found

Controller or its method is not found: {0}::{1}

are those {0}::{1} relevant?
Seems to me like CI is not reading correctly the request


RE: Sub Directory on Controller - andybiancoblu - 09-26-2019

(09-24-2019, 08:34 AM)MGatner Wrote: @andybiancoblu Are you getting an error message? E.g. 404 Not Found.

I don't *think* it would matter but you should try uppercase on your namespace: `App\Controllers\Dashboard`

Also make sure auto-routing is enabled (should be if you didn't change anything) in **app/Config/Routes.php**
Hello again.
I'm desperate! I really want to start developing a project with CI4 because I find it really robust as a framework, but this issue with subfolders is blocking me.

Consider my Routes.php:
Code:
<?php namespace Config;

$routes = Services::routes(true);
if (file_exists(SYSTEMPATH . 'Config/Routes.php'))
{
    require SYSTEMPATH . 'Config/Routes.php';
}

$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Dashboard');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

$routes->get('/', 'App\Controllers\dashboard\Dashboard::index');

if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'))
{
    require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
I omitted deafault comments...

What's wrong with my configuration?
I tried recreating virtualhost config to check if there was something wrong there, but nothing worked.

Can anyone help?