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

  • Home
  • SEARCH
  • 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 9165405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:54:08+00:00 2026-06-17T14:54:08+00:00

I have a front controller that is instantiated as follows: $request = new FrontController();

  • 0

I have a front controller that is instantiated as follows:

$request = new FrontController();
$request->route();

The route() method then dynamically calls the appropriate controller as needed based on the request.

Now (I think) I want all of my controllers to extend the FrontController so that they can all have access to a shared set of methods and properties, but I don’t want them to inherit the route() method as that could potentially lead to an infinite loop. If the route() method is marked as private, however, then I can’t instantiate the object as demonstrated above.

The only solution I’ve found is to call self::route() from the FrontController’s constructor, and then to define a blank constructor in each child controller. That just feels sloppy.

Is there a way to exclude certain methods from inheritance without marking them as private? Or should I be looking at the problem from another angle?

  • 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-17T14:54:09+00:00Added an answer on June 17, 2026 at 2:54 pm

    You can prepend the final modifier to a method to prevent it from being overridden by subclassing.

    class FrontController{
       final public function route() {
           // ...
       }
    }
    

    See the following PHP manual entry for more examples and a detailed explanation:

    http://php.net/manual/en/language.oop5.final.php

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

Sidebar

Related Questions

I have a front controller that works. I wrote a login controller called AuthController.php.
I have a servlet (front-controller), which analyse the request, prepare some necessary data (model)
I am building a site that will (obvisouly) have a front end public portion
I have a lot of front-end code that would be more readable if I
I have simple front controller plugin which contains this code: http://pastebin.com/m155c59b0 When session expire
I have a front controller in my PHP project. Here is the code; .htaccess
i have a conceptual question about Front controller implementation in php. Most of the
I have some dilemma about controller usage. Like usualy, router (dispatcher or front controller)
I'm writing a Java servlet that acts as a Front Controller. To carry out
I am new to ZF.i have made a function that basically make a Form

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.