An autoloader is a feature to allow classes and functions from different files to be included automatically when they are first called. This saves the need to explicitly include all of the files, or create a monstrous global functions/classes file.
Questions tagged [autoloader]
388 questions
5
votes
2 answers
PHP how to include composer autoload in Class file
I got difficult to include composer autoload in Class file, it not working on require_once('../vendor/autoload.php');
require_once('phpmailer/PHPMailerAutoload.php');
require_once('../vendor/autoload.php');
class Test {
function X()
{ ...…

kefoseki
- 71
- 2
- 8
5
votes
3 answers
How to integrate ezComponents with magento
in a 'native' Zend Framework application I would enable the use of ezComponents by adding the autoloader of ezComponents to Zends autoloader:
$autoLoader =…

volka
- 51
- 1
- 3
5
votes
1 answer
class_exists is calling spl_autoload_register
I create a simple script for autoload classes, but when I use class_exists the spl_autoload_register is executed, example:

Protomen
- 9,471
- 9
- 57
- 124
5
votes
1 answer
Fatal error in Autoloader.php on line 34 phpExcel
I want to use phpExcel, but when run the script I get this error:
Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'Multibyte function overloading in PHP must be disabled for string functions (2).' in…

Abduhafiz
- 3,318
- 5
- 38
- 48
5
votes
1 answer
LogicException error: Passed array does not specify an existing static method
here to ask is any error for my autoloader class/function with spl_autoload_register?
appreciate for helping.
here is my code

geass
- 63
- 1
- 4
5
votes
2 answers
SPL Autoloading best practices
In my include_path on the server-side I have a reference to a pear directory, in '/usr/share/pear/'. Within my applications I include files from a common library, living in '/usr/share/pear/library/' with require_once 'library/file.php'.
I've…

meder omuraliev
- 183,342
- 71
- 393
- 434
4
votes
2 answers
form_validation class does not load (codeigniter)
My script fails to load form_validation class.
I called it from autoload.php, controller's _construct method and the method i was intend to use (ie. login() method)
autoload.php
$autoload['libraries'] = array('database', 'Login', 'Template',…

Umur Kontacı
- 35,403
- 8
- 73
- 96
4
votes
2 answers
Is there a way to dynamically change the name of the class being autoloaded?
For instance, say I have the following code.
$foo = new bar();
And an autoloader like this.
function autoload($class_name) {
$class_file_name = str_replace('_', '/', $class_name) . '.php';
if (file_exists($class_file_name)) {
…

dqhendricks
- 19,030
- 11
- 50
- 83
4
votes
1 answer
Laravel 5.3 - ErrorException in ClassLoader.php line 414
I am using Laravel 5.3. I have just installed intervention/image package in my project. Everything is working fine but I am facing an error on a page. I have searched a lot to resolve it but i am unable to solve it. Can anyone help me to resolve…

Mohit Sharma
- 331
- 2
- 11
4
votes
2 answers
Reduce number of included files
My application based on Zend Framework and Doctrine includes > 300 files on each request. They are mostly the same files.
This is a quite huge overhead. Partially solved by Zend_Cache (and Memcache), but not all the pages may be cached.
How to…

takeshin
- 49,108
- 32
- 120
- 164
4
votes
1 answer
Class not found, namespace, subfolder
I have cli app with a couple of classes which resides in /core/modules. Too much, so I want some of them to be in /core/modules/evaluate/ with Class Core\Modules\Evaluate\Something. On my local computer this works, but not on a remote server.
Init…

Matthias Hoffmann
- 41
- 1
4
votes
1 answer
Will PHP Autoloader load when calling a class constant?
I have a class that defines some class constants. It looks something like this phony class for simplicity.
class MyThing {
const BORIS = 'Yeltsin';
}
I'm registering the directory that the class is located like…

Halfstop
- 1,710
- 17
- 34
4
votes
1 answer
Rails 4.1 unable to autoload namespaced class
I've done an helper for nested resource's urls
# app/urls/url.rb
module Url; end
Then
# app/urls/base.rb
module Url
class Base
# common code
end
end
When I try to inherit from Url::Base, a LoadError arise:
Unable to autoload constant Base,…

Iazel
- 2,296
- 19
- 23
4
votes
1 answer
Right way to use external non PSR-0 libraries on Symfony2 project
I'm working on a application that will connect to Intuit Quickbooks API trough theirs REST PHP SDK. In basic PHP I have things working without problem since I load files as follow:
require_once('../api/config.php'); // Default V3 PHP SDK (v2.0.1)…

ReynierPM
- 17,594
- 53
- 193
- 363
4
votes
1 answer
File Directory and autoloading issue PHP MVC
Im building a MVC PHP framework and am having some issues with autoloading my classes, which i think might be down to my file structure.
Firstly, here is my file structure:
Im testing developing in an Xampp localserver environment so this is why i…

Tom Burman
- 947
- 3
- 15
- 37