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
0
votes
2 answers
Trouble with Namepaces and Class Loading
Im building a custom CMS and have setup an autoloader, and have adapted use of namespaces. For the most part things are loading properly, but in certain cases PHP reports that it cannot find the class, the class file has been included.
Once a file…

Richard Testani
- 1,474
- 4
- 15
- 29
0
votes
1 answer
Classmap keyword doesn't insert classes
So in the composer.json i got the following:
"autoload": {
"psr-0" : {
"classmap": ["src/libraries/"]
}
},
and i got a class with path ~\src\libraries\ClassName.php and when I try to make an instance with new…

user1113314
- 803
- 1
- 10
- 24
0
votes
1 answer
Trouble using SplClassLoader
This is my first time writing an application in PHP. I normally developer in Node or MVC4, if that helps any.
Here is my directory structure for this project:
-TestProject
--BackgroundWorkers
---Worker1
----Repositories
…

Sean Lindo
- 1,387
- 16
- 33
0
votes
1 answer
A php runtime error
I have a PHP script which is producing the following error
Parse error: syntax error, unexpected '[', expecting ')' in /home/masked/public_html/masked/AutoLoader.php on line 20
(note that I masked some parts of the directory given as they correspond…

megaman
- 1,035
- 1
- 14
- 21
0
votes
1 answer
Restrict my spl_autoloader to only load classes in my namespace?
I've just begun using autoloader lazy loading in my app, and I'm running afoul of namespacing. The autoloader is trying to load things like new DateTime() and failing. Is there a trick to making my autoloader spcific to only my own namespaced…

RSAdmin
- 419
- 1
- 6
- 20
0
votes
1 answer
PHP classes cannot be loaded unless namescape is included or commented out
After searching through the site, I'm at a loss as to why I'm getting a fatal error about my class not being found unless I either instantiate the class with the namescape prefixing it, or comment out the namescape in the class file. I'm using PSR-0…

canadiancreed
- 1,966
- 6
- 41
- 58
0
votes
1 answer
PHP Autoloading with Composer using Namespaces
I previously had a pretty simple autoload script working nicely, but as I've noticed that Doctrine2 is using Composer for this, I thought it might be nice to streamline everything. Unfortunately, Composer does not seem to be working as I understood…

Tom Clowers
- 141
- 1
- 6
0
votes
2 answers
Autoloader zend
Problems with require_once 'Zend/Library/Autoloader.php'
PHP Warning: require_once(Zend/Loader/Autoloader.php): failed to open stream: No such file or directory in /var/www/DenisApp/scripts/load.sqlite.php on line 13
PHP Fatal error: …

Denis.
- 1
- 1
0
votes
1 answer
How to autoload classes located in subfolders?
I'm trying to autoload classes in PHP that are stored in subfolders within the classes folder. Here is the directory and file structure:
htdocs
SANDBOX
index.php
classes
app
app1.php
utlity
utility1.php
Here are the…

knot22
- 2,648
- 5
- 31
- 51
0
votes
1 answer
php Programming Fatal Error Class 'input' not found in /home/adminl0gin/public_html/login.php on line 21
I've been having this issue for a few days now and though I have made some progress I still have not gotten anywhere. The main issue is finding the classes and autoloading them dynamically as needed. The end result is the outputted error you see in…

Andre F.
- 1,123
- 1
- 10
- 27
0
votes
1 answer
How do I unset spl_autoload_register() and from where does it run?
When using spl_autoload_register(), if I understand correctly, once you run it, PHP saves it for every file.
The question I have, and this is really three questions, is:
How do you remove a function from spl_autoload_register()?
Does…

JVE999
- 3,327
- 10
- 54
- 89
0
votes
1 answer
Autoloading classes in superclass
I'm trying to build my own MVC framework, but I'm having problems with the autoloader.
I have the following directory…

user3343171
- 15
- 4
0
votes
0 answers
Composer: lib (React PHP) only partially autoloading
One component in the React lib is auto-loading, but the majority are not.
I Composed react/react into my project, and everything in that process went smoothly.
Upon trying to use React\EventLoop\Factory or React\Stream\Stream, a "class not found"…

mOrloff
- 2,547
- 4
- 29
- 48
0
votes
1 answer
Autoload classes with varying number of parameters in constructor
I'm working with an existing code base that has been used to deploy multiple web sites. Some of the sites customize a few of the classes. I've built an autoload function that at least finds the classes. Unfortunately, some of the classes have a…

mcarson
- 2,602
- 2
- 14
- 15
0
votes
2 answers
CodeIgniter autoloaded models' variables are lost after an AJAX call
I've been creating an application that requires buttons to make an ajax call to a controller that uses autoloaded models. I was under the impression that variables in an autoloaded model would retain their values after an Ajax call, but for some…

Nick
- 1,082
- 1
- 15
- 27