CodeIgniter Forums

Full Version: How to organize applications ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
What would be recommended for developing a complex application, would everything be within the framework or would it use the framework for each subapplication ?
It really depends on what type of application it is.

You could have and application that has separate backend and frontend.

In CodeIgniter 4 we now have modules so we can divide our applications
into modules.


Admin Module
Blog    Module
CMS    Module

CodeIgniter 4 is just about ready to be released soon so I would start by
designing my new application using CodeIgniter 4 and modules.

That is what I' am doing using now. Building my admin dashboard using

The nice thing about using modules is that once made they are reusable.
so the modules are in the root of the framework. And as would be the structure of CI, I refer to the directories controllers, models, view and others. Would they stay within each module ?
This is how my modules are laid out.

-- Admin - Module
---- Config
---- Controllers
---- etc;
-- Blog - Module
---- Config
---- Controllers
---- etc;
-- assets
-- index.php

I use my name as the main namespace.


Your_name or Company name ( root namespace )
-- Module_name ( Admin )
---- Config
---- Controllers
---- Database
---- Entities
---- Filters
---- Helpers
---- Language
---- Libraries
---- Models
---- Views

A module consists of almost the whole app folder, except you only need the folders
that you are going to use.
In that case how would you interconnect modules? For instance you have a admin structure and a user structure. What if a admin also has some functionality of the user? Is their a way to let the modules (if i can call them that) speak with eachother?
Any module can access any other module there all just classes and name spaced.

This is why you try to keep all your business logic in your models then any module can access
the models.

But any module class can call any class in your application.
Thank you for this thread. I have installed CI4 today with the intention to migrate my sprawling php project scripts.

My project is split into 2 distinct parts.
Public Pages
Admin Area

Given the above explanation it is my intention to do the following:
1)Create a admin folder in the root and copy all app folders/files to the new admin folder

2)Use default namespace and develop all public pages in app folder

Having done this, and having changed admin/config/app.php from public $baseURL = 'http://mydomain/'; to $baseURL = 'http://mydomain/admin/'; I am running into a 404 error when trying to access http://mydomain/admin/ that states Controller or its method is not found: App\Controllers\Admin::index

I'm a little confused as I want to be able both http://mydomain/ and http://mydomain/admin/ independantly.

What am I missing?
You need to create a Config/Routes.php in your Admin folder like above.

This is how I started my Routes this is still a work in progress.

Just an Example below.

PHP Code:

 * Insitefx/Admin: routes file.

$routes->group('', ['namespace' => 'Insitefx\Admin\Controllers'], function($routes)

    $routes->get('dashboard''Admin::dashboard', ['as' => 'dashboard']);


In the route group above change to your namespace.
ahhh! that make sense.

Many thanks.
Pages: 1 2 3