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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:28:52+00:00 2026-06-17T02:28:52+00:00

This might be a bit hard to comprehend so I apologize in advance if

  • 0

This might be a bit hard to comprehend so I apologize in advance if this is not clear enough.

I’m writing my own MVC framework and am once again stuck.

I am in the process of writing the controller classes for the framework. Basically this is how it works:

  • Instantiate class coreController which extends abstract class
  • coreController sets controller to be loaded by interpreting query string
  • query string values stored in variables
  • other variables assigned values
  • new controller is loaded
  • new controller checks if an action object needs to be instantiated.
  • new actioncontroller is loaded
  • action controller checks if it is the final object required.
  • action controller is returned as an object to be referenced during the rest of the script.

generic $controller->method() can be called and references final controller loaded.

Another overview:

coreController
    pageController
       pageControllerActionAdd
       return as object to start

$controller->something(); //References pageControllerActionAdd

Esentially what I want to be able to do is be able enter a url like:
http://www.mywebsite.com/page/modify/

and have the script pull up the PageModifyController as a variable so I can execute it’s methods.

If you can tell me a better method for what I am doing please go ahead. You don’t have to write any code, just the idea would be great. It is just that the way I am currently doing is very confusing and hard to debug. I will end up with multiple nested objects and I don’t like the concept of that.

I’ve been reading a lot of other source code and found that it too can be quite sophisticated.

  • 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-17T02:28:53+00:00Added an answer on June 17, 2026 at 2:28 am

    I actually created a framework that works along the lines you are trying to implement. I think what you are missing is a RoutingHandler class. Routing is the physical manipulation of the URL, which tells your application which Controller to load, and which Action to run.

    In my world I also have Modules, so the basic routing scheme is

    Module -> Controller -> Action
    

    These three items map to my URI scheme in that fashion. Variables can be appended also like so…

    http://www.domain.com/module/controller/action/var1/val1/var2/val2

    So, what happens after the URI is parsed, and control is passed over to the appropriate controller and action? Let’s make some code up to demonstrate a simple example…

    <?php    
        class indexController extends Controller {
    
            protected function Initialize() {
                $this->objHomeModel = new HomeModel;
    
                $this->objHeader = new Header();
                $this->objFooter = new Footer();
    
                $this->objHeader
                    ->SetPageId('home');
            }
    
            public function indexAction() {
                $this->objHeader->SetPageTitle('This is my page title.');
            }
    
            // other actions and/or helper methods...
        }
    ?>
    

    In the Initialize method, I’m setting some controller-wide stuff, and grabbing an instance of my Model to use later. The real meat is in the indexAction method. This is where you would set up stuff to use in your View. For example…

    public function randomAction() {
        $this->_CONTROL->Append($intSomeVar, 42);
    }
    

    _CONTROL is an array of values that I manipulate and pass onto the View. The Controller class knows how to find the right template for the View because it is named after the Action (and in a sibling directory).

    The Controller parent class takes the name of the action method and parses it like so…

    indexAction -> index.tpl.php
    

    You can also do some other fun stuff here, for example…

    Application::SetNoRender();
    

    …would tell the Controller not to render inside a template, but just complete the method. This is useful for those situations where you don’t actually want to output anything.

    Lastly, all of the controllers, models, and views live inside their own Module directory like so…

    my_module
        controllers
            indexController.class.php
            someotherController.class.php
            :
            :
        models
            HomeModel.class.php
            :
            :
        templates
            index.tpl.php
            someother.tpl.php
            :
            :
    

    I can have as many Modules as I need, which means I can separate functionality out by Module and/or Controller.

    I could go on, but I’m writing this from memory, and there are some wrinkles here and there, but hopefully this gives you food for thought.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a bit of a noob question, so I apologize in advance.
It's a bit hard to search for it. This might actually be a Rails
This might not be a hard core programming question, but it's related to some
This might be a bit difficult to explain in writing, so please bear with
This might sound a bit of an odd question but I know what I
This might seem a bit weird, but since I am new in RoR and
Ok this might be a bit of hack but bear with me :) The
I know this might be a bit awkward but I am trying to modify
This might be a little bit odd question, but Im trying to figure out
This might be a little bit picky, but in the iPad SplitViewController setup, there

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.