67938

CodeIgniter - Autoload

I was wondering what the best practices for CodeIgniter's autoload are. Is it bad practice to just autoload everything I might ever need, or is it okay to do so? Does this put more load on the application?

At the moment I'm just autoloading the libraries and helpers I'll be using throughout my application:

$autoload['libraries'] = array('database', 'session', 'parser'); $autoload['helper'] = array('url', 'form');

So I'm basically wondering if this is 'okay' to do or if I should just load some of them when I'm actually going to use them (like the form helper: only load it when I'm actually going to build a form on a page).

Perhaps I'm being a bit too paranoid here, but having read about the 'Ruby way' a lot, I was wondering if there is, maybe, a CodeIgniter way. Thanks in advance!

Answer1:

$autoload loads a resource weather you use it or not period

So that in mind I would only autoload what you need all the time, but if I were to input my 2 cents I always use my __construct for this in the top of each controller class file. That way it loads for all pages (functions) in that class and it isn't autoloading even if i don't need it in that class file.

Answer2:

You should avoid autoload, because it has an impact on your performance. However think like database connection could be autoloaded if you use it frequently.

Php isn't Java, so loaded application don't persist between requests.

Recommend

  • Make sure c++ decimal comparison is correct
  • Mixing Win32 SEH with heap-allocated stack frames
  • Session State v ViewState
  • returning a memoryStream as a string
  • Example for subscribing for BLE indicate in android
  • Cakephp Form Helper
  • Are there algorithms for putting a digest into the file being digested?
  • Play Framework nested form errors missing
  • How do I capture a rsolr Sunspot exception raised on a different thread from a model callback?
  • Ruby and class variables in inherit class
  • Insertion large number of Entities into SQL Server 2012 [duplicate]
  • SSL client cert authentication for only some URLs?
  • Is it possible to run clang with llc flags
  • Most efficient way to move table rows from one table to another
  • VSCode change debug shell to bash on windows
  • SQLite connection strategies
  • Adding elements to a huge XML file
  • How integrated is Collada to OpenGL ES
  • How can I extract results of aggregate queries in slick?
  • Jackson Parser: ignore deserializing for type mismatch
  • Is it possible to access block's scope in method?
  • How to delay loading a property with linq to sql external mapping?
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • How to extract text from Word files using C#?
  • Javascript Callbacks with Object constructor
  • How to check if every primary key value is being referenced as foreign key in another table
  • Sending data from AppleScript to FileMaker records
  • jQuery tmpl and DataLink beta
  • Return words with double consecutive letters
  • Circular dependency while pushing http interceptor
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • SQL merge duplicate rows and join values that are different
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • LevelDB C iterator
  • Can't mass-assign protected attributes when import data from csv file
  • How to get NHibernate ISession to cache entity not retrieved by primary key