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

  • Home
  • SEARCH
  • 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 9110675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:19:33+00:00 2026-06-17T03:19:33+00:00

I am just looking through some core files of Codeigniter and I see that

  • 0

I am just looking through some core files of Codeigniter and I see that it uses some what you might call procedural functions scattered all over the place like to get the instance of the config class somewhere in a core class instead of injecting it into the object it just does

$config =& get_config();

I’m no expert but isn’t that bad to do? To me it seems like making the application have unnecessary global state.

As far as I can see it is nearly the exact same as doing something like

$config = App::loadClass('config');

Is doing it the second way worse than the first? I’m thinking it might be because when calling it the second way the App class needs to exist (and be located) and doing it the first way no specific class must exist and the class file does not need to be included so less requirements.

I am making my own framework and have avoided using any static stuff so far but when I look into the code of the leading frameworks for ideas or help I see static stuff all over the place and I wonder why?

You would think that the leading frameworks would be coded a bit better or maybe using global methods is not as harmful as many people make them out to be what do you think?

In my framework I have to inject this $config object into lots of classes and a $logger object and a $messages/$language and a few more. I use a Dependency Injection container and factories but it’s still a bit of a pain compared to just doing

$config = App::loadClass('config');
$someSetting = $config->setting('some.setting');
Logger::write('debug', 'some message');

If I’m going to use static methods should I use the procedural ones(Codeigniter example) or the ones embedded in classes? or do you strongly advise to never use them?

Any opinions would be great thanks.

  • 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-06-17T03:19:35+00:00Added an answer on June 17, 2026 at 3:19 am

    I’m no expert but isn’t that bad to do? To me it seems like making the application have unnecessary global state.

    Correct. This should be avoided. Not only does it introduce global state, but it also spits out a strict warning:

    Strict Standards: Only variables should be assigned by reference in …

    Is doing it the second way worse than the first?

    Don’t think it is worse, because at least you don’t get the `Strict Standards` warning. But still you would really want to avoid this.

    > I am making my own framework and have avoided using any static stuff so far but when I look into the code of the leading frameworks for ideas or help I see static stuff all over the place and I wonder why?

    This is because of the fact that most popular frameworks out there are terrible. Not only do they introduce bad coding practice, but often they also will also tell you it is using a MVC structure (which most are clearly not).

    > You would think that the leading frameworks would be coded a bit better or maybe using global methods is not as harmful as many people make them out to be what do you think?

    Again those frameworks are full of WTF’s. If you really think you want to look into one of the popular frameworks you should look into Symfony 2 or Zend FW 2. Not because they do everything the correct way, but because they are the best (of the popular ones) imho.

    > In my framework I have to inject this $config object into lots of classes and a $logger object and a $messages/$language and a few more.

    Dependency injection is the correct way to solve this (at least if you are going for an OOP approach). However if you classes have a lot of dependencies you might have to stop for a moment and think about the fact the perhaps your classes are doing too much. A.k.a they have [too many responsibilities](http://en.wikipedia.org/wiki/Single_responsibility_principle).

    > If I’m going to use static methods should I use the procedural ones(Codeigniter example) or the ones embedded in classes? or do you strongly advise to never use them?

    Strongly advice against both. As you already stated in introduces global state. Make testing a pain. And has more to do with procedural programming than OOP.

    *P.S. I have giving you the two best FW’s in my opinion. If you want to know CodeIgniter and Cake are the worst.*

    To finish this post a somewhat related message from [the PHP chatroom](https://chat.stackoverflow.com/transcript/11?m=6055399#6055399) by [Lusitanian](https://chat.stackoverflow.com/users/1477526/lusitanian):

    > *Microframework* (n): A small amount of crap. See also *Framework* (n): A large amount of crap.

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

Sidebar

Related Questions

I have an application that is looking through some files for old data. In
Just looking through the newly released Gingerbread documents and I see they've added some
I'm just looking through some of the webmaster stats that Google provides , and
I was just looking through some information about Google's protocol buffers data interchange format.
I am looking through some old code and found a piece that i cant'
Looking through some java code and this just does not seem right. To me,
This isn't actually homework, I'm just looking through some questions in a discrete maths
I was looking through a code tutorial just now, and found something interesting --
Just looking on resources that break down how frames per second work. I know
Basically just looking to see if you can capture an image from the webcam

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.