CodeIgniter Forums
How to organize applications ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Best Practices (https://forum.codeigniter.com/forum-12.html)
+--- Thread: How to organize applications ? (/thread-75058.html)

Pages: 1 2 3


How to organize applications ? - jocm.aguiar - 12-15-2019

What would be recommended for developing a complex application, would everything be within the framework or would it use the framework for each subapplication ?


RE: How to organize applications ? - InsiteFX - 12-15-2019

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.

Example

Admin Module
Blog    Module
CMS    Module
etc;

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
AdminLTE.

The nice thing about using modules is that once made they are reusable.


RE: How to organize applications ? - jocm.aguiar - 12-17-2019

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 ?


RE: How to organize applications ? - InsiteFX - 12-17-2019

This is how my modules are laid out.

app
Insitefx
-- Admin - Module
---- Config
---- Controllers
---- etc;
-- Blog - Module
---- Config
---- Controllers
---- etc;
public_html
-- assets
-- index.php
system
writable

I use my name as the main namespace.


RE: How to organize applications ? - InsiteFX - 12-22-2019

Yes,

app
public
system
etc;

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.


RE: How to organize applications ? - ZoeF - 04-14-2020

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?


RE: How to organize applications ? - InsiteFX - 04-14-2020

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.


RE: How to organize applications ? - 68thorby68 - 04-24-2020

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?


RE: How to organize applications ? - InsiteFX - 04-25-2020

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:
<?php

/**
 * Insitefx/Admin: routes file.
 */

$routes->group('', ['namespace' => 'Insitefx\Admin\Controllers'], function($routes)
{
    $routes->get('admin''Admin::index');
    $routes->get('admin/(:any)''Admin::view/$1');

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

}); 

In the route group above change to your namespace.


RE: How to organize applications ? - 68thorby68 - 04-25-2020

ahhh! that make sense.



Many thanks.