Class not found after “require_once”
I get the following error:
`Fatal error: Class 'DummyClass' not found in...`
<?php
require_once("3rdparty/simplesaml/lib/_autoload.php");
class login extends DummyClass { (this is the line the error refers to)
[...]
}
?>
If I comment out the require_once
it works perfectly fine.
DummyClass is defined externally and can be found in the prepend-file. (I don't think it matters for this problem as it works as expected if I comment out require_once
)
The path to the file should also be correct as it gives me a "Failed opening required..." Error if I change the path.
I also tried switching between PHP 5.6 and 7 - no difference.
So, I would like to ask you for help. Do you have any hints / ideas, why I might get that error?
php class require-once
add a comment |
I get the following error:
`Fatal error: Class 'DummyClass' not found in...`
<?php
require_once("3rdparty/simplesaml/lib/_autoload.php");
class login extends DummyClass { (this is the line the error refers to)
[...]
}
?>
If I comment out the require_once
it works perfectly fine.
DummyClass is defined externally and can be found in the prepend-file. (I don't think it matters for this problem as it works as expected if I comment out require_once
)
The path to the file should also be correct as it gives me a "Failed opening required..." Error if I change the path.
I also tried switching between PHP 5.6 and 7 - no difference.
So, I would like to ask you for help. Do you have any hints / ideas, why I might get that error?
php class require-once
1
This sounds like it could be an issue of namespacing. What namespace isDummyClass
defined in and what namespace is your script in now? IfDummyClass
is in the default namespace, doesextends DummyClass
help?
– Michael Berkowski
Nov 23 '18 at 17:28
1
Another thing to ask - were you using an autoload function already before including the simplesaml autoload?
– Michael Berkowski
Nov 23 '18 at 17:35
Yes, the prepend-file contains afunction __autoload($classname){
. TheDummyClass
did not help. Although, I am just trying to figure out the namespaces. As it's a whole framework behind "DummyClass", it's not as easy to just echo something.
– TheElbenreich
Nov 23 '18 at 17:52
__NAMESPACE__ does not contain anything, neither with or without the problematic line.
– TheElbenreich
Nov 23 '18 at 17:57
add a comment |
I get the following error:
`Fatal error: Class 'DummyClass' not found in...`
<?php
require_once("3rdparty/simplesaml/lib/_autoload.php");
class login extends DummyClass { (this is the line the error refers to)
[...]
}
?>
If I comment out the require_once
it works perfectly fine.
DummyClass is defined externally and can be found in the prepend-file. (I don't think it matters for this problem as it works as expected if I comment out require_once
)
The path to the file should also be correct as it gives me a "Failed opening required..." Error if I change the path.
I also tried switching between PHP 5.6 and 7 - no difference.
So, I would like to ask you for help. Do you have any hints / ideas, why I might get that error?
php class require-once
I get the following error:
`Fatal error: Class 'DummyClass' not found in...`
<?php
require_once("3rdparty/simplesaml/lib/_autoload.php");
class login extends DummyClass { (this is the line the error refers to)
[...]
}
?>
If I comment out the require_once
it works perfectly fine.
DummyClass is defined externally and can be found in the prepend-file. (I don't think it matters for this problem as it works as expected if I comment out require_once
)
The path to the file should also be correct as it gives me a "Failed opening required..." Error if I change the path.
I also tried switching between PHP 5.6 and 7 - no difference.
So, I would like to ask you for help. Do you have any hints / ideas, why I might get that error?
php class require-once
php class require-once
edited Nov 23 '18 at 18:39
Zoe
11.4k74078
11.4k74078
asked Nov 23 '18 at 17:22
TheElbenreichTheElbenreich
87
87
1
This sounds like it could be an issue of namespacing. What namespace isDummyClass
defined in and what namespace is your script in now? IfDummyClass
is in the default namespace, doesextends DummyClass
help?
– Michael Berkowski
Nov 23 '18 at 17:28
1
Another thing to ask - were you using an autoload function already before including the simplesaml autoload?
– Michael Berkowski
Nov 23 '18 at 17:35
Yes, the prepend-file contains afunction __autoload($classname){
. TheDummyClass
did not help. Although, I am just trying to figure out the namespaces. As it's a whole framework behind "DummyClass", it's not as easy to just echo something.
– TheElbenreich
Nov 23 '18 at 17:52
__NAMESPACE__ does not contain anything, neither with or without the problematic line.
– TheElbenreich
Nov 23 '18 at 17:57
add a comment |
1
This sounds like it could be an issue of namespacing. What namespace isDummyClass
defined in and what namespace is your script in now? IfDummyClass
is in the default namespace, doesextends DummyClass
help?
– Michael Berkowski
Nov 23 '18 at 17:28
1
Another thing to ask - were you using an autoload function already before including the simplesaml autoload?
– Michael Berkowski
Nov 23 '18 at 17:35
Yes, the prepend-file contains afunction __autoload($classname){
. TheDummyClass
did not help. Although, I am just trying to figure out the namespaces. As it's a whole framework behind "DummyClass", it's not as easy to just echo something.
– TheElbenreich
Nov 23 '18 at 17:52
__NAMESPACE__ does not contain anything, neither with or without the problematic line.
– TheElbenreich
Nov 23 '18 at 17:57
1
1
This sounds like it could be an issue of namespacing. What namespace is
DummyClass
defined in and what namespace is your script in now? If DummyClass
is in the default namespace, does extends DummyClass
help?– Michael Berkowski
Nov 23 '18 at 17:28
This sounds like it could be an issue of namespacing. What namespace is
DummyClass
defined in and what namespace is your script in now? If DummyClass
is in the default namespace, does extends DummyClass
help?– Michael Berkowski
Nov 23 '18 at 17:28
1
1
Another thing to ask - were you using an autoload function already before including the simplesaml autoload?
– Michael Berkowski
Nov 23 '18 at 17:35
Another thing to ask - were you using an autoload function already before including the simplesaml autoload?
– Michael Berkowski
Nov 23 '18 at 17:35
Yes, the prepend-file contains a
function __autoload($classname){
. The DummyClass
did not help. Although, I am just trying to figure out the namespaces. As it's a whole framework behind "DummyClass", it's not as easy to just echo something.– TheElbenreich
Nov 23 '18 at 17:52
Yes, the prepend-file contains a
function __autoload($classname){
. The DummyClass
did not help. Although, I am just trying to figure out the namespaces. As it's a whole framework behind "DummyClass", it's not as easy to just echo something.– TheElbenreich
Nov 23 '18 at 17:52
__NAMESPACE__ does not contain anything, neither with or without the problematic line.
– TheElbenreich
Nov 23 '18 at 17:57
__NAMESPACE__ does not contain anything, neither with or without the problematic line.
– TheElbenreich
Nov 23 '18 at 17:57
add a comment |
1 Answer
1
active
oldest
votes
Problem solved.
The old framework was using the old __autoload
function, which is deprecated.
SimpleSAMLPHP used the new function. Those autoload-combinations cause one of them to override the other.
Solution:
Switch from __autoload
to spl_autoload_register
.
Similar Question: Override vendor autoload composer
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450779%2fclass-not-found-after-require-once%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Problem solved.
The old framework was using the old __autoload
function, which is deprecated.
SimpleSAMLPHP used the new function. Those autoload-combinations cause one of them to override the other.
Solution:
Switch from __autoload
to spl_autoload_register
.
Similar Question: Override vendor autoload composer
add a comment |
Problem solved.
The old framework was using the old __autoload
function, which is deprecated.
SimpleSAMLPHP used the new function. Those autoload-combinations cause one of them to override the other.
Solution:
Switch from __autoload
to spl_autoload_register
.
Similar Question: Override vendor autoload composer
add a comment |
Problem solved.
The old framework was using the old __autoload
function, which is deprecated.
SimpleSAMLPHP used the new function. Those autoload-combinations cause one of them to override the other.
Solution:
Switch from __autoload
to spl_autoload_register
.
Similar Question: Override vendor autoload composer
Problem solved.
The old framework was using the old __autoload
function, which is deprecated.
SimpleSAMLPHP used the new function. Those autoload-combinations cause one of them to override the other.
Solution:
Switch from __autoload
to spl_autoload_register
.
Similar Question: Override vendor autoload composer
edited Nov 24 '18 at 0:30
answered Nov 24 '18 at 0:18
TheElbenreichTheElbenreich
87
87
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450779%2fclass-not-found-after-require-once%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
This sounds like it could be an issue of namespacing. What namespace is
DummyClass
defined in and what namespace is your script in now? IfDummyClass
is in the default namespace, doesextends DummyClass
help?– Michael Berkowski
Nov 23 '18 at 17:28
1
Another thing to ask - were you using an autoload function already before including the simplesaml autoload?
– Michael Berkowski
Nov 23 '18 at 17:35
Yes, the prepend-file contains a
function __autoload($classname){
. TheDummyClass
did not help. Although, I am just trying to figure out the namespaces. As it's a whole framework behind "DummyClass", it's not as easy to just echo something.– TheElbenreich
Nov 23 '18 at 17:52
__NAMESPACE__ does not contain anything, neither with or without the problematic line.
– TheElbenreich
Nov 23 '18 at 17:57