cmc-sales/app/webroot/test_setup.php

111 lines
3.5 KiB
PHP
Raw Normal View History

2025-08-07 20:31:27 -07:00
<?php
/**
* CakePHP Setup Test
*/
echo "<h1>CakePHP Setup Test</h1>";
// Test 1: PHP Version
echo "<h2>PHP Information</h2>";
echo "<p><strong>PHP Version:</strong> " . PHP_VERSION . "</p>";
echo "<p><strong>Server API:</strong> " . php_sapi_name() . "</p>";
// Test 2: Required Extensions
echo "<h2>PHP Extensions</h2>";
$extensions = ['mysql', 'mysqli', 'gd', 'curl', 'mbstring'];
foreach ($extensions as $ext) {
$loaded = extension_loaded($ext);
echo "<p><strong>$ext:</strong> " . ($loaded ? '✓ Loaded' : '✗ Not Loaded') . "</p>";
}
// Test 3: CakePHP Constants
echo "<h2>CakePHP Constants</h2>";
$constants = ['ROOT', 'APP_DIR', 'CAKE_CORE_INCLUDE_PATH', 'WWW_ROOT'];
foreach ($constants as $const) {
if (defined($const)) {
echo "<p><strong>$const:</strong> " . constant($const) . "</p>";
} else {
echo "<p><strong>$const:</strong> ✗ Not defined</p>";
}
}
// Test 4: File System
echo "<h2>File System</h2>";
$paths = [
'/var/www/cmc-sales',
'/var/www/cmc-sales/cake',
'/var/www/cmc-sales/app',
'/var/www/cmc-sales/app/webroot'
];
foreach ($paths as $path) {
$exists = file_exists($path);
$readable = is_readable($path);
echo "<p><strong>$path:</strong> " .
($exists ? '✓ Exists' : '✗ Missing') .
($readable ? ', ✓ Readable' : ', ✗ Not readable') . "</p>";
}
// Test 5: CakePHP Core
echo "<h2>CakePHP Core Test</h2>";
$cake_bootstrap = '/var/www/cmc-sales/cake/bootstrap.php';
if (file_exists($cake_bootstrap)) {
echo "<p><strong>CakePHP Bootstrap:</strong> ✓ Found at $cake_bootstrap</p>";
// Try to include it
try {
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', '/var/www/cmc-sales');
}
if (!defined('ROOT')) {
define('ROOT', '/var/www/cmc-sales');
}
if (!defined('APP_DIR')) {
define('APP_DIR', 'app');
}
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
echo "<p><strong>Include Test:</strong> Ready to include CakePHP</p>";
// Note: We don't actually include it here to avoid conflicts
} catch (Exception $e) {
echo "<p><strong>Include Test:</strong> ✗ Error - " . $e->getMessage() . "</p>";
}
} else {
echo "<p><strong>CakePHP Bootstrap:</strong> ✗ Not found</p>";
}
// Test 6: Database
echo "<h2>Database Test</h2>";
$db_host = $_ENV['DB_HOST'] ?? 'db-staging';
$db_user = $_ENV['DB_USER'] ?? 'cmc_staging';
$db_pass = $_ENV['DB_PASSWORD'] ?? '';
$db_name = $_ENV['DB_NAME'] ?? 'cmc_staging';
echo "<p><strong>DB Host:</strong> $db_host</p>";
echo "<p><strong>DB User:</strong> $db_user</p>";
echo "<p><strong>DB Name:</strong> $db_name</p>";
if (function_exists('mysqli_connect')) {
$conn = @mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if ($conn) {
echo "<p><strong>Database Connection:</strong> ✓ Connected</p>";
mysqli_close($conn);
} else {
echo "<p><strong>Database Connection:</strong> ✗ Failed - " . mysqli_connect_error() . "</p>";
}
} else {
echo "<p><strong>Database Connection:</strong> ✗ MySQLi not available</p>";
}
echo "<h2>Server Information</h2>";
echo "<pre>";
echo "Document Root: " . $_SERVER['DOCUMENT_ROOT'] . "\n";
echo "Script Name: " . $_SERVER['SCRIPT_NAME'] . "\n";
echo "Working Directory: " . getcwd() . "\n";
echo "</pre>";
echo "<p><small>Generated at: " . date('Y-m-d H:i:s') . "</small></p>";
?>