05-25-2018, 12:50 AM
I wanted to organize my code in modules. In the documentation, I found the modular code and followed all the instructions. But I did not succeed, help, please, understand the reason.
1. application/Config/Autoload.php add:
2. create folders:
/application/
/modules->Node->Controllers and Config
/public
...
3. chage value in /application/Config/Routes.php (false into true) :
4. create Controller in /modules/Node/Controllers/Node.php and Routes in /modules/Node/Config/Routes.php:
Now visit http://mysite.com/node/any and I get 404 ...
Please point out my mistakes, thank you! (I will be grateful for the examples of Routes.php and other)
1. application/Config/Autoload.php add:
PHP Code:
class Autoload extends \CodeIgniter\Config\AutoloadConfig
{
public $psr4 = ['Modules' => ROOTPATH.'modules'];
...
/application/
/modules->Node->Controllers and Config
/public
...
3. chage value in /application/Config/Routes.php (false into true) :
PHP Code:
$routes->discoverLocal(true);
PHP Code:
//in controller
class Node extends \CodeIgniter\Controller
{
public function index()
{
echo "Say Hi!";
}
}
//in routes
$routes->get('node/(:any)', 'Modules\Node\Controllers\Node::index');
Now visit http://mysite.com/node/any and I get 404 ...
Please point out my mistakes, thank you! (I will be grateful for the examples of Routes.php and other)