What is the best practice for organizing files like index.php and database setup for a PHP shop?

When organizing files for a PHP shop, it is best practice to create separate folders for different functionalities such as "controllers", "models", and "views". This helps in maintaining a clean and structured codebase. Additionally, it is recommended to keep database setup code in a separate file for better organization and reusability.

// Example folder structure:
// - controllers
// - models
// - views
// - config
//   - database.php

// database.php
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}