Welcome Guest, Not a member yet? Register   Sign In
Rewrite Kohana cascading filesystem to CodeIgniter with namespaces
#1

(This post was last modified: 08-03-2020, 12:37 PM by Edwin82.)

Hello,

We have a self developed Content Management System, bases on Kohana Framework. Kohana is not supported anymore, so we are searching for another framework. Kohana was once created from CodeIgniter and I have some experience with CodeIgniter. Kohana and Codeigniter are still somewhat similar. There are a lot of differences of course, but I think it is more easy to rewrite the code to CodeIgniter then to Laravel or any other framework.

We are using the cascading filesystem on Kohana to add a new 'layer' between system and application.
Lets say we have this structure:

root
  /application (Website dependent exceptions). This folder is called 'app' in CodeIgniter.
  /inzite (Our CMS base code)
  /modules (Kohana folder)
  /system (Kohana folder)

The CMS is used for hundreds of websites. Every website has his own instance of the code. The base CMS code is in the 'cms' folder. The exceptions for every site are in the 'application' folder. This can be Views, Controller, Model, etc.

So, instead of having
root
  /application
  /system

we have
root
  /application
  /inzite
  /system

This gives us the advantage to update the cms folder, without touching the application folder. That makes an update easier. We are not using namespaces, but we want to do that in the future.

Now I want to say more about the folder structure.

root
  /application/classes/Controller/Page.php (Optional. Does not have to exist. Only when there is an exception.)
    class Controller_Page extends Inzite_Controller_Page {}

  /application/classes/Model/Page.php (Optional. Does not have to exist[b][i]. Only when there is an exception.)[/i][/b]
    class Model_Page extends Inzite_Model_Page {}

  /cms/classes/Controller/Page.php (This is a dummy file)
    class Controller_Page extends Inzite_Controller_Page {}

  /cms/classes/Model/Page.php (This is a dummy file)
    class Model_Page extends Inzite_Model_Page {}

  /cms/classes/Inzite/Controller/Page.php:
    class Inzite_Controller_Page extends ORM

  /cms/classes/Inzite/Model/Page.php:
    class Inzite_Model_Page extends ORM

The Page model can have a function like this.

public static function getPages() {}

We call the function with:
Model_Page::getPages();

Model_Page is always available. It can be from the dummy file or from the custom file in the application folder. The function can always be called with Model_Page::function(), because both the dummy and custom (application) file are extending the 'Inzite-class' from the base functionality.

That is why we are using this dummy files.

CodeIgniter does not have a cascading filesystem. We want to do something like our current design, but with the CodeIgniter structure and with namespaces.

It is important to understand that we have a basic CMS folder (/inzite) and a custom folder (/application) with exceptions specific to the website in question. That makes an update easier than when the CMS and custom code are mixed up in the same files and folder.

Is this setup possible with namespaces in CodeIgniter?
I hope you can help me with the first steps.
Reply
#2

Hi, the closes thing we got are Code Modules, so that you can re-use your code (cms part) and make individual applications.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB