模块视图文件在 Codeigniter 4 中显示无效

Module view file showing invalid in Codeigniter 4

我已经在 ...\app\Config\Autoload.php

中添加了模块文件夹
public $psr4 = [
          APP_NAMESPACE => APPPATH, // For custom app namespace
          'Config'      => APPPATH . 'Config',
          'Blog'      => ROOTPATH . 'example/blog',
];

我的目录:

/Home directory of main project folder
/example
    /Blog
        /Config
            /Routes.php
        /Controllers            
            /Blog.php
        /Views
           /show_blog.php

Routes.php

namespace Config;

// Create a new instance of our RouteCollection class.
$routes = Services::routes();

$routes->get('blog', 'blog::index', ['namespace' => 'Blog\Controllers']); 

Blog.php

namespace Blog\Controllers;

class Blog extends \CodeIgniter\Controller {

    function index() { 
        echo view('Example\Blog\Views\show_blog');
    }

} 

在运行my_domain/index.php/blog之后,显示了这个错误:

CodeIgniter\View\Exceptions\ViewException

Invalid file: Example\Blog\Views\show_blog.php

没有从这个问题中得到任何解决方案:Codeigniter 4 View file invalid

我哪里错了?

Blog.php改成这个,对我有用。

namespace Blog\Controllers;

class Blog extends \CodeIgniter\Controller {

    function index() { 
        echo view('Blog\Views\show_blog');
    }

} 

来源:CI 论坛