title: Organizing a PHP project
body: <h2>What It Is</h2>
  
  <p>Here is what I've done so far:</p>
  
  <ul>
  <li><strong>core/</strong>
  
  <ul>
  <li><strong>controllers/</strong> <em>(contains the controllers used by the app)</em></li>
  <li><strong>models/</strong> <em>(contains the models used by the app)</em></li>
  <li><strong>views/</strong> <em>(contains the views used by the app)</em></li>
  <li>base_controller.php <em>(the controller every other extend)</em></li>
  <li>base_model.php <em>(the model every other extend)</em></li>
  </ul></li>
  <li><strong>vendors/</strong>
  
  <ul>
  <li>phprouter/ <em>(a simple router class)</em></li>
  <li>pimple/ <em>(a simple DI container class)</em></li>
  </ul></li>
  <li>configuration.php <em>(contains all the app configuration)</em></li>
  <li>index.php <em>(includes the configuration, vendors, base model, base controller, sets the DI container up and route the request)</em></li>
  </ul>
  
  <p>See the code here: <a href="http://pastebin.com/pxUpUvv6" rel="noreferrer">http://pastebin.com/pxUpUvv6</a><br>
  <em>Please note that the given code is just an example, therefore the controllers, models, views aren't in place yet. Also, it may be buggy—as untested—, but it doesn't matter right now.</em></p>
  
  <h2>Request Flow</h2>
  
  <ol>
  <li>The client requests <em>index.php</em>.</li>
  <li>The configuration, vendors, base controller, base model are included.</li>
  <li>The DI container and the dependencies are initialized, we can now inject them anywhere.</li>
  <li>We map controllers to URL and the router does its job.</li>
  <li>The controller is fetched (although this is not in the example code, as noted above).
  
  <ul>
  <li>We do some stuff.</li>
  <li>The method then calls <code>::call_model()</code>, which includes the corresponding model from <em>core/models/</em>, and then calls the same method we're using from the model class corresponding.</li>
  </ul></li>
  <li>The model is fetched.
  
  <ul>
  <li>More stuff.</li>
  <li>The model then calls <code>::call_view()</code>', which includes the corresponding view from <em>core/views/</em>.</li>
  </ul></li>
  <li>The view is fetched and render the page to the client.</li>
  </ol>
  
  <h3>FYI: Corresponding</h3>
  
  <p>Examples of controller, model, view which correspond:</p>
  
  <ul>
  <li>Controller <code>Controller_Products::list()</code> at <em>core/controllers/Controller_Products.php</em></li>
  <li>Model <code>Model_Products::list()</code> as <em>core/models/Model_Products.php</em></li>
  <li>View at <em>core/views/Model_Products_list.php</em></li>
  </ul>
  
  <h2>Issues Being Faced</h2>
  
  <p>Actually, I feel a bit uncomfortable with this structure. Dunno, it seems to be far from scalable, modulable...</p>
  
  <ol>
  <li>Does <em>only</em> the basic <em>folder</em> structure—<code>core{, /controllers, /models/, /views}</code>, <code>vendors</code> at the root—looks good to you?</li>
  <li>I feel like I should get <code>__autoload()</code> outside of <em>index.php</em>, which seems a little too big to me. If so, what about DI container?</li>
  <li>Maybe if I get to needing more than two external library, it should be better not to have them included one by one, manually? But how?</li>
  <li>Putting all the configuration in a file <em>configuration.php</em> at the root looks to me like old-fashioned PHP4. Thanks to the power of <a href="http://pimple-project.org/" rel="noreferrer">Pimple</a>, I could embed this configuration directly into it but yet, where?</li>
  <li>I think the way I handle <code>::call_model()</code> (<em>core/base_controller.php</em>) and <code>::call_view()</code> (<em>core/base_model.php</em>) is a bit awkward. Would you agree? What'd be a simplified way to redo the whole thing?</li>
  <li>Considering all my issues, would it eventually be better for me to use a framework as Symfony?</li>
  </ol>
  
  <p>If something isn't clear, feel free to ask.<br>
  Thanks.</p>