Welcome Guest, Not a member yet? Register   Sign In
Using and namespacing 'modules'

(This post was last modified: 04-20-2020, 02:36 AM by Zeff.)

UPDATE - 2020-04-20

I changed App\Config\Autoload.php to:

PHP Code:
<?php namespace Config;

SYSTEMPATH 'Config/AutoloadConfig.php';

 * -------------------------------------------------------------------
 * -------------------------------------------------------------------
 * This file defines the namespaces and class maps so the Autoloader
 * can find the files as needed.
class Autoload extends \CodeIgniter\Config\AutoloadConfig
$psr4 = ['Start'  => APPPATH 'Modules/Start']; 

Added a route for the start module in App\Config\Routes.php:

PHP Code:
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
 and updated App\Modules\Start\Controllers\Start.php:

PHP Code:
namespace App\Modules\Start\Controllers;
//namespace Start\Controllers;

use App\Controllers\BaseController;

Start extends BaseController

    public function index()
        return view('../Modules/Start/Views/start/index');

    public function foo()
        return view(''../Modules/Start/Views/start/foo');

When I open http://localhost/ci4-test/start --> Bingo! It works
But when I open  http://localhost/ci4-test/start/foo: 404 - 'Controller or its method is not found: App\Controllers\Start::foo'

Is there something wrong in my routing file?

Thanks for any help or suggestion!


Yesterday, I was playing around with namespaces in a test application but it won't work out...

I created a subfolder 'Start' within  'App\Modules' (namespaced as 'Mine' in autoloader.php - see lower)
[Image: 0?ui=2&ik=fe539f4545&attid=0.1&permmsgid..._k92l7fk00]
In namespaced the controller and added the namespace to the autoloader:
[Image: 0?ui=2&ik=fe539f4545&attid=0.2&permmsgid..._k92lft991]
But it looks like the regular App\Controllers\ route is still followed...
[Image: 0?ui=2&ik=fe539f4545&attid=0.3&permmsgid..._k92lhhg72]
Any idea what I'm doing wrong?

Many tanks in advance!


Theme © iAndrew 2016 - Forum software by © MyBB