Create multiple CodeIgniter 3 applications using one installation
CodeIgniter 3 allows you to create multiple applications using one installation by simple creating multiple application folders, each with a unique name. However, sometimes you may want your applications to share some resources for example you want your applications to share the same models, libraries and even configuration files.
For you to be able to easily do this, your can modify the CodeIgniter core/Config and core/Loader so that it can fetch resources from a location different from the respective application folder. You can create this "shared" resources folder in the root of your application and then create your normal models and libraries the same way you would do in your application folders.
This package allows you to create the following shared resources:
- models
- libraries
- config (including database config)
- helpers
- language
Once you have created these resources, you will be able to load and use them exactly the same way you would with your files in application folders. N:B. Your files in the shared resources can be overridden or extended by files in your application folders, same way you override system files in your application folders. You can also override or extend system files in the shared folder by using the MY_filename.php method.
- The root application will be inside the
site
folder and served byindex.php
- The admin application will be inside the
admin
folder and served by admin.php
- Download an install CodeIgniter.
- Rename
application
folder tosite
- Create a copy of the
site
folder and name itadmin
- Download / clone this repository into the directory you installed CodeIgniter
- Copy contents of
application
folder into both thesite
andadmin
folders. - Delete CodeIgniter default
index.php
file - Copy
index.sample.php
toindex.php
- Open
index.php
and change$application_folder = 'application';
to$application_folder = 'site';
somewhere around line116
- Copy
index.sample.php
toadmin.php
- Open
index.php
and change$application_folder = 'application';
to$application_folder = 'admin';
somewhere around line116
Your directory structure should look like this:
--root
|
|--site/
|--admin/
|--shared/
|--system/
|--index.php
|--admin.php