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 8849907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:46:31+00:00 2026-06-14T12:46:31+00:00

I am trying to delve into MVC with Front Controller Design. I want to

  • 0

I am trying to delve into MVC with Front Controller Design.

I want to invoke my entire application by using one line, for example in index.php:

require_once(myclass.php);
$output = new myClass();

I would love to get rid of the require_once line, but I don’t see how I could load my class without including it?

Anyway my main question would be how to load my various controllers and models and views etc using a one front end class. So far I have come up with:

class myClass
{
    private $name;
    public $root = $_SERVER['DOCUMENT_ROOT'];
    private $route = array("Controller" => "", "Model" => "", "View" => "", "Paremeters" => "");
    function __construct() 
    {   $uri = explode("/",$_SERVER['REQUEST_URI']);
        if(isset($uri[2])) {$this->route['Controller'] = $uri[2];}
        if(isset($uri[3])) {$this->route['Model'] = $uri[3];}
        if(isset($uri[4])) {$this->route['View'] = $uri[4];}
        if(isset($this->route['Controller'])) 
        {
            include($this->root."/".$this->route['Controller'].".php");
        }
    }

}

But it seems a bit convoluted and over the top. Also, once i’ve included the new class in the __construct, How am I supposed to load it?

Im sorry for the lack of knowledge, I have googled this a number of times and I keep coming up with the same pages that don’t seem to expand my knowledge on the matter.

  • 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-14T12:46:32+00:00Added an answer on June 14, 2026 at 12:46 pm

    I’m surprised that in those two long and informative previous answers nobody bothered to actually answer your question in the simplest way.

    You want the __autoload() function. You’ll still have to define it somewhere in your code, but it can simply be added to a global header file and then you don’t have to explicitly write an include for every class definition.

    /* auto load model classes */
    function __autoload($class_name) {
            $filename = 'class.' . strtolower($class_name) . '.php';
            $file = __SITE_PATH . '/_model/' . $filename;
            if( file_exists($file) == false ) {
                    return false;
            }
            require($file);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to insert values with Unicode Chars into a MySQL-database using Delphi 2010 and
I am Using Linq to Entity MVC and when I am trying to delte
This is an academic question, more than a practical one. I'm trying to delve
I'm trying to delve into the depths of the murky world of Tumblr, and
Recently I have been trying to delve into advanced (well for me) programming concepts
I'm very new to iPhone programming, but am trying to delve into it. I
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Before I delve into it, I'm very new to Android and I have just
I'm working on a biology web based application and trying to figure out what
the following code is an example of something I'm trying to do in a

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.