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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:12:06+00:00 2026-05-15T23:12:06+00:00

Okay, so I am creating an MVC framework in PHP and I want it

  • 0

Okay, so I am creating an MVC framework in PHP and I want it to be pretty flexible. This is all fine – I’m working on this at the moment and things are going well (So I don’t want to use Zend or another pre-existing framework, haha!), but I wanted to make both the framework and application quite dynamic. I’ll try explain:

Here’s a simplified directory structure:

- index.php           (wants to use app1 or app2 depending on domain name)
- /app1               (wants to use framework 1.1)
    - /config
        - config.php  
- /app2               (wants to use framework 1.2)
    - /config
        - config.php  
- /framework_1.1
- /framework_1.2

A Bootstrap file /index.php receives all incoming requests. It will then load a certain application’s config file from /app1/config/config.php or /app2/config/config.php, etc, depending on a certain condition, say.. the HTTP host:

// /index.php
switch ( $_SERVER[ 'HTTP_HOST' ] ) {
    case 'localhost':
        $app_root = ROOT . 'app1/';
        break;
    case 'site.com':
        $app_root = ROOT . 'app2/';
        break;
    default:
        $app_root = ROOT . 'application/';
        break;
}
define('APP_ROOT', $app_root);

The bootstrap file then loads the application’s config file:

// /index.php
include( APP_ROOT . 'config/config.php' );

A $config array will be returned from the application’s config file, which will indicate where the framework files are located.

// /app2/config/config.php
$config['framework_root'] = '/framework_1.2/';

Bootstrap runs that framework.

// /index.php
include( $config['framework_root'] . 'config/bootstrap.php' );

Is this the best way to go about this?

The only problem with this, is that the /index.php file has to know about all possible applications, so the user will need to edit the switch statement in /index.php (or a /apps.php file that the /index.php includes, maybe?).

Also, the application’s configuration file has to be loaded before loading the framework’s files, which seems a bit weird to me…

Is there a simple way for making it so the request specifies application, and the application specifies which framework to use, or is the above way the simplest?

Sorry if this was confusing! Confused me a bit writing it 😉

  • 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-05-15T23:12:07+00:00Added an answer on May 15, 2026 at 11:12 pm

    I use Symfony most of the time, so I will apply my knowledge there when answering your questions:

    Is there a simple way for making it so the request specifies application

    Use multiple “index.php” (or use ?app=xxx) with a URL-rewrite combo. That makes things a bit cleaner.

    Also, the application’s configuration file has to be loaded before loading the framework’s files, which seems a bit weird to me…

    It’s not weird, you certainly need to configure and initiate some states before bootstrapping your framework, but perhaps you may want to provide sub-class of your framework’s bootstrap class, to define what shall be done during framework bootstrapping.

    I recommend you to look into Symfony2 to find out how they modularize/manage libraries and dependencies. Seriously, there’s no reason to write another framework but to contribute to an existing one – unless you find them not sharing the same visions with yours.

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

Sidebar

Related Questions

Okay this one's pretty straightforward. I'm creating a checkbox in my Page.xaml.cs file, and
Okay, so here's my problem: We use FOP for creating pretty report output. We
Okay, I'm trying to get ActionBarSherlock working, so I imported the library by: Creating
Okay I am probably going to get a load of down votes for this
Okay, this question has evolved a bit, and I want to try to start
Okay so I am pretty much doing a crash course through creating a java
Okay, so I am creating a ticker of sorts, and I had some pretty
Okay I will first admit I don't know the proper terminology for all this
Okay so basically I am creating a Workflow BPMS in SharePoint and I want
Okay, this is a bit abstract, but here goes: I'm creating a website and

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.