Subscribe to PHP Freaks RSS

TutsPlus.com: How to Manage Multiple Applications in CodeIgniter

syndicated from www.phpdeveloper.org on November 28, 2017

The TutsPlus.com site has posted a new tutorial showing the CodeIgniter users out there how to manage multiple sites written using the framework. Traditionally CodeIgniter applications needed to be run as separate instances but their method simplifies the setup by needing only one instance for all.

Today, we’re going to explore how you can manage multiple applications in the CodeIgniter web framework using a single codebase. In the course of that, we’ll go ahead and create two different CodeIgniter applications that will share the core CodeIgniter codebase.

Sharing the core codebase across different applications is not something new as it’s already practiced by different frameworks and open-source systems, and CodeIgniter is no different. It easily allows you to manage multiple applications that share the core CodeIgniter library and API files, and at the same time you could use different databases and site-specific configurations.

The article then starts with some of the benefits of using a multisite setup including simpler maintenance and the ability to use different databases for each. It then gets into the process for creating multiple applications using separate directories under an "applications" directory and creating sample "welcome" content under each. Finally, they make some changes to the configuration to use an environment variable to switch out which front controller (index.php) file to direct the request to (as set up in the web server config).