Class not found after “require_once”












0















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?










share|improve this question




















  • 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






  • 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){. 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


















0















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?










share|improve this question




















  • 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






  • 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){. 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
















0












0








0








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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





    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













  • __NAMESPACE__ does not contain anything, neither with or without the problematic line.

    – TheElbenreich
    Nov 23 '18 at 17:57
















  • 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






  • 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){. 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










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














1 Answer
1






active

oldest

votes


















0














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






share|improve this answer

























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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






    share|improve this answer






























      0














      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






      share|improve this answer




























        0












        0








        0







        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






        share|improve this answer















        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







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 24 '18 at 0:30

























        answered Nov 24 '18 at 0:18









        TheElbenreichTheElbenreich

        87




        87






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Different font size/position of beamer's navigation symbols template's content depending on regular/plain...

            Berounka

            I want to find a topological embedding $f : X rightarrow Y$ and $g: Y rightarrow X$, yet $X$ is not...