title: Files & Classes structure in OOP PHP
body: <p>I'm fairly new too OOP and PHP and I've been reading up on tutorials and books to get the hang of it. Right now i'm working on an personal project (no tutorial or book exercise) and I've got a question on how to organise my classes and files.</p>
  
  <p>I've got a database.php file in which I create my connection with my database, and in the __construct function of my classes i call upon it, like so:</p>
  
  <pre><code>&lt;?php
  
  include 'database.php';
  
  class users {
  
  // Database Connection
  public function __construct() {
    $db = new database();
  }
  
  // the rest of my functions
  
  ?&gt;
  </code></pre>
  
  <p>The problem/question I have is that in the tutorials and exercises i did, there was only one class. Currently in my project I have 3 classes (users, movies and watchlists) and they all have a .php file (users.php, movies.php and watchlists.php)</p>
  
  <p>On certain pages in my project I need data from all 3 classes so I start those pages like so:</p>
  
  <pre><code>&lt;?php
  session_start();
  
  include 'include/users.php';
  include 'include/movies.php';
  include 'include/watchlists.php';
  $user = new users();
  $movie = new movies();
  $watchlist = new watchlists();
  
  // the rest of the file
  </code></pre>
  
  <p>Now, its pretty obvious to me that this is not the right way when you have multiple classes, as I'm creating a database connection three times in a row.</p>
  
  <p>So how do I manage my classes, database connection and .php files correctly when working on a project like mine?</p>
  
  <p>You don't have to explain the whole thing, if you can link me to some great articles/tutorials about this, it will be greatly appreciated. (Yes, I have googled it but couldn't find anything helpful).</p>
  
  <p>Thanks</p>