Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6338451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:26:51+00:00 2026-05-24T19:26:51+00:00

I have a CI website which contains two application folders, one for the front

  • 0

I have a CI website which contains two application folders, one for the front end (users) and another for the admin user:

/applications/front/
/applications/admin/

Inside the /applications/front/helpers/ we have some classes like MY_url_helper.php, and then because we want to use this in the admin area, we have the same exact code in
/applications/admin/helpers/MY_url_helper.php – so when we modify the code, it’s in two places.

As you can imagine, this goes against SOO many rules! What’s a better way of sharing the same helpers/libraries with two applications on a single website with CI?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:26:52+00:00Added an answer on May 24, 2026 at 7:26 pm

    Well, you have a few options:

    • Leave things the way they are and don’t worry about “breaking the rules”. You will most likely find that, eventually, you will need a very different codebase for your admin/control panel than for your front end – so duplication becomes a non-issue as you end up writing different code.

    • Integrate both applications into one. This solves the duplication issue but causes others, like the need to balance each library or helper to work appropriately in both environments. My experiences with this are exposed in greater detail here, and there is a blog post by CI developer Phil Sturgeon that sums up how to implement this practice here: http://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter

    • This is one I haven’t used but looks promising: Packages.

    Application “Packages”

    An application package allows for the easy distribution of complete
    sets of resources in a single directory, complete with its own
    libraries, models, helpers, config, and language files. It is
    recommended that these packages be placed in the
    application/third_party folder.

    Regardless of the recommendation to use the /third_party directory, this can be any directory you choose.

    The following is an example of a directory for an application package
    named “Foo Bar”. /application/third_party/foo_bar

    config/
    helpers/
    language/
    libraries/
    models/

    Whatever the purpose of the “Foo Bar” application package, it has its
    own config files, helpers, language files, libraries, and models. To
    use these resources in your controllers, you first need to tell the
    Loader that you are going to be loading resources from a package, by
    adding the package path. $this->load->add_package_path()

    Adding a package path instructs the Loader class to prepend a given
    path for subsequent requests for resources. As an example, the “Foo
    Bar” application package above has a library named Foo_bar.php. In our
    controller, we’d do the following:

    $this->load->add_package_path(APPPATH.'third_party/foo_bar/');
    $this->load->library('foo_bar');

    The full details are explained on the docs for the Loader: http://codeigniter.com/user_guide/libraries/loader.html

    And once again, here is another post by Phil Sturgeon about it that may help you understand how it works: http://philsturgeon.co.uk/blog/2010/04/codeigniter-packages-modules

    The idea here is that you would have a third “application” folder (your “package”) which would be used as a fallback for loading resources, while allowing you to override the file by placing a matching one in either of the other applications, so you get the benefit of shared resources with the flexibility of being able to override them *.

    * This is the assumption I am under from reading the docs, I have not tested this so there may be more to it.

    You would probably want to place the package directory next to your other two application folders, and reference it in MY_Controller::__construct() like:

    $this->load->add_package_path(FCPATH.'my_package_name/');
    

    I haven’t used yet packages myself, but after writing this post – I’m very tempted to check it out for my next project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables. One contains information on hotels, added to my website by
I have two tables. One contains information on hotels, added to my website by
I have a solution that contains two projects. One project is an ASP.NET Web
I have a website which contains french, with accents é, è, à,.... The website
My colleagues have create a website and there is a webpage which contains a
Let's say I have a main folder in my website named test which contains
On my server, I have two users, www-data (which is used by nginx) and
heys guys, i have a website, which contains lots of db work to display
I have a solution which contains the following: Website Project (using local IIS 7
I have a library class which contains two methods, say, Login() and NavigateToPage(). Now,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.