title: Group classes or traits unto one base class
body: <p>I'm achieving something like create component base application e.g.</p>
  
  <pre><code>-- loader.php
      -- comonents folder
          -- router.php
          -- database.php
          -- payment.php
          -- other components...
  </code></pre>
  
  <p>In <code>loader.php</code> consist of a base class supposedly which will group all components file from components folder so front app can access all components through that base class e.g.</p>
  
  <p>loader.php</p>
  
  <pre><code>class loader{
      // components here
  }
  
  $loader = new loader;
  </code></pre>
  
  <p>then in my front app I can just do..</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;?php require_once(__DIR__.'/loader.php'); ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;?php $loader-&gt;router(); ?&gt; // get router.php component and use
      &lt;/head&gt;
      ....
  </code></pre>
  
  <p>Now, components can be created using <code>php trait</code> and just do</p>
  
  <pre><code>class loader{
      use Router, Database...; // put all traits
  }
  </code></pre>
  
  <p>so they can be accessible through the loader class but the problem is whenever I create or delete a component, I don't want to go to <code>class loader</code> to edit the call of all of the traits, it should be automatically reflected. In current capability of a php reflection and inheritance, seems not possible. Is there a way in PHP to achieve this such idea?</p>
  
  <p>I can create a config and add all components file name e.g.</p>
  
  <pre><code>$config['components'] = [ 'Router', 'Database' ...
  </code></pre>
  
  <p>and just do this in <code>loader.php</code> and eliminate the base class </p>
  
  <pre><code>foreach( $config as $c ){
     require_once(__DIR__.'/components/'.$c.'.php');
     $$c = new $c(); // array value to variable then initialize component class using array value since name all the way are the same
  }
  </code></pre>
  
  <p>then in front app, do</p>
  
  <pre><code>&lt;?php require_once(__DIR__.'/loader.php'); ?&gt; // compose of loop components
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;?php $router(); ?&gt; // get router.php component and use
      &lt;/head&gt;
  </code></pre>
  
  <p>But as much as possible I don't want to do that, I want to group all traits or class base components if possible to a one base class then just that base class will be callable to the front app (index.php). </p>