'error', 'message' => 'This script must be run from CLI']); exit(1); } // Check PHP version and path echo "PHP Version: " . PHP_VERSION . "\n"; echo "PHP Binary: " . PHP_BINARY . "\n"; echo "PHP SAPI: " . php_sapi_name() . "\n"; // Check if OPCache is enabled if (!function_exists('opcache_get_status')) { echo json_encode(['status' => 'error', 'message' => 'OPCache is not installed']); exit(1); } // Get OPCache status $status = opcache_get_status(false); if ($status === false) { echo json_encode(['status' => 'error', 'message' => 'Failed to get OPCache status']); exit(1); } // Get OPCache configuration $config = opcache_get_configuration(); if ($config === false) { echo json_encode(['status' => 'error', 'message' => 'Failed to get OPCache configuration']); exit(1); } // Format the response $response = [ 'status' => 'success', 'data' => [ 'enabled' => $config['directives']['opcache.enable'], 'memory_usage' => [ 'used' => $status['memory_usage']['used_memory'], 'free' => $status['memory_usage']['free_memory'], 'wasted' => $status['memory_usage']['wasted_memory'], 'current_wasted_percentage' => $status['memory_usage']['current_wasted_percentage'] ], 'interned_strings_usage' => [ 'buffer_size' => $status['interned_strings_usage']['buffer_size'], 'used_memory' => $status['interned_strings_usage']['used_memory'], 'free_memory' => $status['interned_strings_usage']['free_memory'], 'number_of_strings' => $status['interned_strings_usage']['number_of_strings'] ], 'opcache_statistics' => [ 'num_cached_scripts' => $status['opcache_statistics']['num_cached_scripts'], 'num_cached_keys' => $status['opcache_statistics']['num_cached_keys'], 'max_cached_keys' => $status['opcache_statistics']['max_cached_keys'], 'hits' => $status['opcache_statistics']['hits'], 'misses' => $status['opcache_statistics']['misses'], 'blacklist_misses' => $status['opcache_statistics']['blacklist_misses'], 'blacklist_miss_ratio' => $status['opcache_statistics']['blacklist_miss_ratio'], 'opcache_hit_rate' => $status['opcache_statistics']['opcache_hit_rate'] ], 'configuration' => [ 'directives' => $config['directives'] ] ] ]; echo json_encode($response, JSON_PRETTY_PRINT);