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 6353897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:29:24+00:00 2026-05-24T22:29:24+00:00

When you name a controller it is usually something along the lines of Blog

  • 0

When you name a controller it is usually something along the lines of Blog
When you name a model it is usually along the lines of Blog_model
When you name a library it is usually along the lines of Blog_lib

Then when you load either a model or a library you load them through
$this->load->model('blog_model') or $this->load->library('blog_lib')

Then you access them through
$this->blog_model->do_something() or $this->blog_lib->do_something()

Because if this you cannot have e.g. your models and controllers and libraries having the same name.

Now I am wondering why Code Igniter does not allow you to access them through e.g.
$this->load->model('blog'); $this->model->blog->do_something()

Which to me is a lot nicer.

Is this a Code Igniter restriction, or is this a restriction in because of PHP?

I.e if I felt the urge, could I modify code Igniter to do this, or would I still run into cannot redeclare class blog… type errors?

If this is the case could Code Igniter not be modified to allow you to name your libraries blog_library and blog_model but then the loader strips off the _model and _library when you access it?

  • 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-24T22:29:24+00:00Added an answer on May 24, 2026 at 10:29 pm

    I dont think this is a restriction in PHP. Its how CI is designed. But it is surely possible to modify the core files espeiclaly that of the loader class to achieve what you want but it might be a overkill. For me i find this type of system really easy to work with and the code is easily understandable at a later point of time.

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

Sidebar

Related Questions

How do make CodeIgniter correctly load controller classes if I want to name them
I have a get-parameter with name controller . When I try to pass it
I would like to have 4 actions with the same name (controller methods may
I have the following route: routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL with
What is the problem below? routes.MapRoute( Default2, // Route name {controller}/{action}/{id}, // URL with
How can I get the controller name of a relative Url, using the routes
How can I get the controller name out of the object if I don't
I have a action on my controller (controller name is 'makemagic') called 'dosomething' that
When I try to change a view controller name in the .h and .m
Is there a class in the ASP.NET MVC framework that represents a controller name

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.