Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:03:07+00:00 2026-06-15T23:03:07+00:00

I currently am working on an autoloader class for one of my projects. Below

  • 0

I currently am working on an autoloader class for one of my projects. Below is the code for the controller library:

     public static function includeFileContainingClass($classname) {

        $classname_rectified = str_replace(__NAMESPACE__.'\\', '', $classname);
        $controller_path     = ENVIRONMENT_DIRECTROY_CONTROLLERS.strtolower($classname_rectified).'.controller.php';

        if (file_exists($controller_path)) {

           include $controller_path;
           return true;

        } else {

           // TODO: Implement gettext('MSG_FILE_CONTROLLER_NOTFOUND')
           throw new Exception('File '.strtolower($classname_rectified).'.controller.php not found.');
           return false;

        }

     }

And here’s the code of the file I try to invoke the autoloader on:

  try {

     spl_autoload_register(__NAMESPACE__.'\\Controller::includeFileContainingClass');

  } catch (Exception $malfunction) {

     die($malfunction->getMessage());

  }

  // TESTING ONLY
  $test = new Testing();

When I try to force a malfunction, I get the following message:

Fatal error: Uncaught exception 'Exception' with message 'File testing.controller.php not found.' in D:\cerophine-0.0.1-alpha1\application\libraries\controller.library.php:51 Stack trace: #0 [internal function]: application\Controller::includeFileContainingClass('application\Tes...') #1 D:\cerophine-0.0.1-alpha1\index.php(58): spl_autoload_call('application\Tes...') #2 {main} thrown in D:\cerophine-0.0.1-alpha1\application\libraries\controller.library.php on line 51

What seems to be wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:03:09+00:00Added an answer on June 15, 2026 at 11:03 pm

    Because you are not catching it…

    spl_autoload_register(__NAMESPACE__.'\\Controller::includeFileContainingClass');
    
    try {
        $test = new Testing();
    } catch (Exception $malfunction) {
        die($malfunction->getMessage());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im currently working with CodeIgniter. My Front Controller loads 1 of 2 Library depending
Our team is currently working on completely redesigning our school's website and one of
Currently working on a code I realized that it used to call malloc multiple
I currently working on a library for the NekoVM to create a binding to
Im currently working on a c# project that uses another .net library. This library
Currently working on a project in MVC-3. Trying to put the following code in
Currently working on a project where we need to drop in various static html
Currently working on a legacy script (PHP) for one of my customers. He just
Currently working on a little Windows Phone (7.5) application and one of the pages
currently working on an app at work that uses a tab bar controller. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.