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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:52:35+00:00 2026-05-26T11:52:35+00:00

am writing a small set of framework structures for PHP (not be confused with

  • 0

am writing a small set of framework structures for PHP (not be confused with a MVC style framework) and I would to like to validate my approach because it seems very “clumsy”:

All requests are piped to a bootstraper through redirect directive (apache htaccess).
All necessary files are required by the bootstrapper.
Then user classes are called based on routes (this works fine, not included here)
Each user module extends core module, that in turn instantiates support classes like DB and CACHE, thus inherits the instances and I don’t have to care about opening/managing connections or if I instantiate other classes within those classes – I don’t have to pass my db/cache as arguments. Also, if I have a large request with plenty of user class methods calls within the same request – I think it would only use one instance of the core.module – which should be a good thing. Right? Right?

However, the config passing seems to be iffy: I hate GLOBALS with passion – BUT I cant make a static config class because I can not put the array there (no static arrays in PHP). Also, this breaks all the IDE intellisenses and the devs are mad at me 🙁

Does the whole approach make sense? Should I go RTM more?

Thank you for your honest opinions, the pseudo-code is attached below.

//my_config_prod.php
<?php
      $CONFIG = array('db' => array(..multi-level array here..), 'cache' => array(...));
?>

//bootstraper.php
<?php
      require '../config/my_config_prod.php';
      require '../core/core.mysql.php';
      require '../core/core.cache.php';
      require '../core/core.module.php';
      require '../class/class.user.php';

      //initialize things:
      $GLOBALS['DB'] = new CoreMysql($CONFIG['db']);
      $GLOBALS['CACHE'] = new CoreCache($CONFIG['cache']);

      //run, this is simplified - route handler is installed here that will 
      //call appropriate module based on the incoming request

      $user = new User();
      $info = $user->load_user(1);
 ?>  

 //core.module.php
 <?php
       public function __construct () {
            global $CACHE;
            $this->cache = $CACHE;

            global $DB;
            $this->db = $DB;
       }
 ?>

 //class.user.php
 <?php
       class User extends CoreModule{

           public function __construct() {
             parent::__construct();
           }

           public function load_user($id) {
             return $this->db->get_user($id)
           }
       }
  ?>
  • 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-26T11:52:35+00:00Added an answer on May 26, 2026 at 11:52 am

    Your globals are kind of registry pattern. You may store the config in object instead of the array, this would be a better approach.

    For the best reference, take a look at Zend Framework 2 configs, bootstraps and application resources.

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

Sidebar

Related Questions

I'm writing a small application in VB.NET and I would like some of the
I am writing a small web server and would like to send gzipped data.
Coming from a PHP background, I'm used to writing small functions that return a
Im just writing a small Ajax framework for re-usability in small projects and i've
I am writing a small framework in C# for importing data to SQL Server.
I am writing a desktop utility application to manage a small set of data.
I'm writing a small qt app suite that consists of a set of small
I'm writing a small data structures library in C#, and I'm running into an
I have an application where I am reading and writing small blocks of data
I'm trying to practice my F# by writing small console scripts in F# in

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.