CodeIgniter Forums
How to setup another modules with new route files? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: How to setup another modules with new route files? (/showthread.php?tid=80113)



How to setup another modules with new route files? - sr13579 - 09-15-2021

I want to create many modules for my applications. After trying very hard i have finally added another module with controller. It is working. But there are some redundancy I want to avoid. And I want to make these modules reusable. That is why I want some suggestions on how I can do that.
It would be very helpful if anyone can help me with writing and adding a new route file in app/Config/Routes.php for a new new module URI mapping. i am not that good with searching that is why I need some direct knowledge about these.


RE: How to setup another modules with new route files? - paliz - 09-15-2021

for new module 
PHP Code:
<?php namespace Modules\App\Config;

use 
CodeIgniter\Config\BaseConfig;

class 
ModuleAppConfig extends BaseConfig
{
    /*
  *---------------------------------------------------------------
  *  x directory
  *---------------------------------------------------------------

  */
    public $xDirectory __DIR__ '/../../../public/upload/x';


Code:
<?php namespace Modules\App\Config;


use Config\Services as BaseService;

class Services extends BaseService
{
    //--------------------------------------------------------------------



}

route.php 

Code:
<?php

/*
* modules\App route.file.
*/

$routes->group('api', ['namespace' => 'Modules\App\Controllers'], function ($routes) {

    $routes->resource('overView');
    $routes->resource('graph');

});