You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug?
Namespace in routes. Value set in $routes->setDefaultNamespace('App\Controllers'); is not used when doing $routes->get('/', 'Core\Dashboard::index');.
CodeIgniter 4 version
CodeIgniter 4.0.0.0-rc3
Affected module(s)
Routing
Expected behavior, and steps to reproduce if appropriate
The controller app/Controller/Core/Dashboard.php:
<?php namespace App\Controllers\Core;
use App\Controllers\BaseController;
class Dashboard extends BaseController
{
public function index()
{
return 'Hello';
}
}
Using it like this in app/Config/Routes.php:
$routes->setDefaultNamespace('App\Controllers');
$routes->get('/', 'Core\Dashboard::index'); // Core is the namespace
$routes->get('/one', 'Core\ExampleOne::index'); // Core is the namespace
$routes->get('/two', 'Testing\ExampleTwo::index'); // Testing is the namespace
This would be an error and would be a 404 page not found. The value set in $routes->setDefaultNamespace('App\Controllers'); is not used.
This works though (but....):
$routes->setDefaultNamespace('App\Controllers'); // Not used at all
$routes->get('/', 'App\Controller\Core\Dashboard::index');
$routes->get('/one', 'App\Controller\Core\ExampleOne::index');
$routes->get('/two', 'App\Controller\Testing\ExampleTwo::index');
or
$routes->setDefaultNamespace('App\Controllers'); // Not used at all unless below $baseNamespace is used
$baseNamespace = $routes->getDefaultNamespace();
$routes->get('/', $baseNamespace . '\Core\Dashboard::index');
$routes->get('/one', $baseNamespace . '\Core\ExampleOne::index');
$routes->get('/two', $baseNamespace . '\Testing\ExampleTwo::index');
or
$routes->setDefaultNamespace('App\Controllers'); // Not used at all
$routes->get('/', 'Dashboard::index', ['namespace' => 'App\Controllers\Core']);
$routes->get('/one', 'ExampleOne::index', ['namespace' => 'App\Controllers\Core']);
$routes->get('/two', 'ExampleTwo::index', ['namespace' => 'App\Controllers\Testing']);
// $routes->group() also works
// $routes->group('', ['namespace' => '', function ($routes) {}]);
Context
OS: Windows 10 Pro 64bit
Web server: N/A
PHP version: 7.3.10
The text was updated successfully, but these errors were encountered:
yrneh-mi
added
the
bug
Verified issues on the current code behavior or pull requests that will fix them
label
Nov 21, 2019
Bug?
Namespace in routes. Value set in
$routes->setDefaultNamespace('App\Controllers');
is not used when doing$routes->get('/', 'Core\Dashboard::index');
.CodeIgniter 4 version
CodeIgniter 4.0.0.0-rc3
Affected module(s)
Routing
Expected behavior, and steps to reproduce if appropriate
The controller
app/Controller/Core/Dashboard.php
:Using it like this in
app/Config/Routes.php
:Expected output:
Actual output:
This would be an error and would be a 404 page not found. The value set in
$routes->setDefaultNamespace('App\Controllers');
is not used.This works though (but....):
or
or
Context
The text was updated successfully, but these errors were encountered: