• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI4 Modules Code not work

#1
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:
PHP Code:
class Autoload extends \CodeIgniter\Config\AutoloadConfig
{
public 
$psr4 = ['Modules' => ROOTPATH.'modules'];

... 
2. create folders:
/application/
/modules->Node->Controllers and Config
/public
...
3. chage value in /application/Config/Routes.php (false into true) :
PHP Code:
$routes->discoverLocal(true); 
4. create Controller in /modules/Node/Controllers/Node.php and Routes in /modules/Node/Config/Routes.php:
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)
Reply


Messages In This Thread
CI4 Modules Code not work - by Nome - 05-25-2018, 12:50 AM
RE: CI4 Modules Code not work - by InsiteFX - 05-27-2018, 04:47 AM
RE: CI4 Modules Code not work - by Nome - 05-28-2018, 08:35 AM
RE: CI4 Modules Code not work - by dave friend - 05-27-2018, 06:54 AM
RE: CI4 Modules Code not work - by Nome - 05-28-2018, 08:28 AM
RE: CI4 Modules Code not work - by blaasvaer - 09-02-2020, 12:28 PM
RE: CI4 Modules Code not work - by dave friend - 05-28-2018, 11:03 AM
RE: CI4 Modules Code not work - by Nome - 06-04-2018, 03:51 AM
RE: CI4 Modules Code not work - by InsiteFX - 06-04-2018, 04:23 AM
RE: CI4 Modules Code not work - by Nome - 06-04-2018, 04:40 AM
RE: CI4 Modules Code not work - by InsiteFX - 09-03-2020, 04:46 AM
RE: CI4 Modules Code not work - by blaasvaer - 09-03-2020, 04:49 AM
RE: CI4 Modules Code not work - by InsiteFX - 09-03-2020, 08:10 AM
RE: CI4 Modules Code not work - by blaasvaer - 09-03-2020, 08:18 AM
RE: CI4 Modules Code not work - by InsiteFX - 09-04-2020, 08:30 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.