Questions tagged [autoload]

autoload is a language convention which allows missing classes or method dependencies to be loaded on-demand.

autoload is implemented differently among languages which include it:

  • Perl's AUTOLOAD allows you to dynamically interpret method calls.
  • PHP's __autoload loads classes. To handle missing methods, the __call() magic method may be used.
  • Ruby's autoload command loads modules.
1633 questions
0
votes
1 answer

How to Include or Autoload Class Files in Solarium for SOLR

I'm Trying to include or autoload Solarium for SOLR in PHP and I keep getting errors. I know I'm doing it incorrectly but I'm new to autoloading. I have the extension installed for php and that works. Here is the error I receive: Fatal error: Class…
stwhite
  • 3,156
  • 4
  • 37
  • 70
0
votes
1 answer

TYPO3 autoload of external classes

I like to use autoload in TYPO3 6.0< for external classes e.g. Symfony\Component\Yaml. Is there an easier way to create an autoload than ext_autoload.php? The library I what to use have very much classes to define if using ext_autoload. Thanks in…
user2513437
  • 155
  • 10
0
votes
1 answer

What's wrong with my autoloader?

I'm trying to register a few autoloaders and I get an HTTP 500. My error log says the following: [05-Aug-2013 04:32:38 UTC] PHP Fatal error: Uncaught exception 'LogicException' with message 'Function 'Autoloader::config' not callable…
Aaron
  • 95
  • 12
0
votes
1 answer

Autoload classes if script need them. What if my php file is in another folder?

I found useful code that helps me keep my code readable. function class_autoload($classname) { echo "class_autoload"; @require_once ("class-{$classname}.php"); } spl_autoload_register('class_autoload'); It loads classes, when server need…
Piotrek
  • 10,919
  • 18
  • 73
  • 136
0
votes
1 answer

typo3: does autoloader only work in root dir of an extension?

I know that I can put a file called ext_autoload.php in the root directory of my typo3 4.7 extension. This will load all classes mentioned in the ext_autoload.php file. However, when I put an ext_autoload.php file in a subdirectory of a backend…
knb
  • 9,138
  • 4
  • 58
  • 85
0
votes
1 answer

PHP 5.3: Using __autoload() to instantiate a class inside another class

I'm reasonably green with OOP, and I can't quite intuit how composition and __autoload() are supposed to work together. What I'm currently trying to build is a class which will have as it's properties quite a number of other classes. To give some…
Jonline
  • 1,677
  • 2
  • 22
  • 53
0
votes
1 answer

Using registerNamespaces() in autoload.php

I use Symfony and I need to add couple bundles in my autoload.php file, which is in .../app/ folder. So, I basically wrote this: registerNamespaces(array( …
user1499804
  • 227
  • 2
  • 6
  • 11
0
votes
2 answers

PHP Autoloading

I've been looking around quite a bit and can't find a concise answer to this question anywhere- perhaps those of you with more experience autoloading than myself could shed some light. Pretty simple question: I wrote a simple autoloader: function…
dudewad
  • 13,215
  • 6
  • 37
  • 46
0
votes
1 answer

PSR-0 autoloader: Namespaces and the directory structure

Does the PSR-0 autoloader convention require using namespaces that map to the directory structure? function autoload($className) { $className = ltrim($className, '\\'); $fileName = ''; $namespace = ''; if ($lastNsPos =…
0
votes
1 answer

JQM Load Page in Javascript Function

I need to open my second page (id=objectside) in JQM Mobil after it's been alert in JavaScript: function showObjekt(val){ $.getJSON('getObjectDetails.php?ido='+val, function(data) { //Overwrite divs in page objectside with…
0
votes
1 answer

PHP Autoload function load from different directories

I have a MVC that is structored like this Modules -Mod1 -controller -Model -View -Mod2 -controller -Model -View and than I have an autoload function that I need it to load all the files in the directory Model, regardless of what Module it…
Ahmad Khan
  • 529
  • 1
  • 7
  • 24
0
votes
1 answer

Auto Load (View More) at the end of the page

I have this piece of code and the 'view more' buttom gets initiated only when the mouse hovers over it, but I want to initiate the 'view more' button when at the end of the page. Any help on this how to do this? …
Nirmalya Ghosh
  • 2,298
  • 3
  • 18
  • 33
0
votes
1 answer

Yeoman auto-load models

Is it possible to load every file in app/scripts/models directory automatically or do I have to reference every single file in index.html? I want to have a model-per-file for my Ember app and that would make a lot of lines. Don't want to write…
mreq
  • 6,414
  • 4
  • 37
  • 57
0
votes
1 answer

Zend Framework 2: Autoload classmap

I generated the classmap of our project to improve its performance in production. I'm surprised because the generated file is really big (more than 5000 lines). It includes the whole ZF2 library, Doctrine, etc. Is it normal or should I exclude the…
Guilhem Soulas
  • 1,975
  • 2
  • 18
  • 30
0
votes
1 answer

Autoload doesn't works if I try to create an instance of a class from inside other function

helper.php : Required at the top of index.php function __autoload($className) { $path = ROOT_DIR.'/class/'.strtolower(trim($className)).'.class.php'; if (file_exists($path)) { require_once($path); } } function…
1 2 3
99
100