Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.idea/
vendor/
.phpunit.cache/
.phpunit.result.cache
/coverage/
93 changes: 93 additions & 0 deletions check-env.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* Environment Variable Diagnostic Tool
*
* Run this to check if your .env file is being loaded correctly
*
* Usage: php check-env.php /path/to/your/app/root
*/

if ($argc < 2) {
echo "Usage: php check-env.php /path/to/app/root\n";
exit(1);
}

$rootPath = $argv[1];
$envFile = $rootPath . '/config/.env';

echo "=== Environment Diagnostic Tool ===\n\n";

// Check if .env file exists
echo "1. Checking .env file...\n";
echo " Path: $envFile\n";
if (!file_exists($envFile)) {
echo " ❌ .env file NOT FOUND!\n";
echo " Create a .env file at: $envFile\n\n";
exit(1);
} else {
echo " ✅ .env file exists\n";
echo " Size: " . filesize($envFile) . " bytes\n\n";
}

// Load dotenv
echo "2. Loading .env file...\n";
require_once $rootPath . '/vendor/autoload.php';

try {
$dotenv = \Dotenv\Dotenv::createImmutable($rootPath . '/config');
$dotenv->safeLoad();
echo " ✅ Dotenv loaded successfully\n\n";
} catch (Exception $e) {
echo " ❌ Error loading dotenv: " . $e->getMessage() . "\n\n";
exit(1);
}

// Check database variables
echo "3. Checking database environment variables...\n";
$dbVars = [
'DB_ADAPTER',
'DB_HOSTNAME',
'DB_NAME',
'DB_USERNAME',
'DB_PASSWORD',
'DB_PORT',
'DB_SOCKET',
'DB_PREFIX'
];

$missing = [];
foreach ($dbVars as $var) {
$valueEnv = $_ENV[$var] ?? null;
$valueGetenv = getenv($var);

if (!$valueEnv && !$valueGetenv) {
echo " ❌ $var: NOT SET\n";
$missing[] = $var;
} else {
$value = $valueEnv ?: $valueGetenv;
// Hide password
if ($var === 'DB_PASSWORD') {
$display = $value ? '***' : '(empty)';
} else {
$display = $value ?: '(empty)';
}
echo " ✅ $var: $display\n";
}
}

echo "\n";

// Summary
if (count($missing) > 0) {
echo "⚠️ Missing variables: " . implode(', ', $missing) . "\n";
echo "Add these to your .env file: $envFile\n\n";
} else {
echo "✅ All database variables are set!\n\n";
}

// Check APP_ENV
$appEnv = $_ENV['APP_ENV'] ?? getenv('APP_ENV');
echo "4. Application Environment\n";
echo " APP_ENV: " . ($appEnv ?: 'NOT SET') . "\n\n";

echo "=== Diagnostic Complete ===\n";
108 changes: 85 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,89 @@
{
"name": "jwele329/rpc",
"version": "1.1.6",
"license": "MIT",
"description": "Reusable PHP Components",
"authors": [
{
"name": "Justin Welenofsky",
"email": "jwelenofsky@three29.com"
}
],
"require": {
"php": ">=5.6.0",
"vlucas/phpdotenv": "2.*",
"filp/whoops": "2.*",
"kint-php/kint": "2.*"
},
"require-dev" : {
"php": ">=5.6.0"
"name": "jwele329/rpc",
"version": "2.0.0-beta.3",
"license": "MIT",
"description": "Reusable PHP Components",
"authors": [
{
"name": "Justin Welenofsky",
"email": "jwelenofsky@three29.com"
}
],
"config": {
"platform": {
"php": "8.3.0"
}
},
"require": {
"php": ">=8.3.0",
"vlucas/phpdotenv": "^5.6.2",
"filp/whoops": "^2.18",
"kint-php/kint": "^6.1",
"ext-gd": "*",
"psr/container": "^2.0",
"psr/event-dispatcher": "^1.0",
"ext-pdo": "*"
},
"require-dev": {
"php": ">=8.3.0",
"phpunit/phpunit": "^12.4.5",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^2.1"
},
"autoload": {
"psr-4": {
"RPC\\": "src/RPC/"
},
"autoload": {
"psr-0": {
"RPC": "src/"
},
"files": ["src/RPC/init.php"]
"files": [
"src/RPC/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit",
"test:unit": "phpunit tests/Unit",
"test:feature": "phpunit tests/Feature",
"test:coverage": "phpunit --coverage-html coverage",
"test:coverage-text": "phpunit --coverage-text",
"compat": "phpcs --standard=phpcs.xml",
"compat:summary": "phpcs --standard=phpcs.xml --report=summary",
"compat:full": "phpcs --standard=phpcs.xml -s",
"phpstan": "phpstan analyze --level=5 --memory-limit=512M",
"phpstan:baseline": "phpstan analyze --level=5 --memory-limit=512M --generate-baseline",
"static": "@phpstan",
"lint": [
"@compat",
"@phpstan",
"@test"
],
"check": [
"@compat:summary",
"@test"
],
"ci": [
"@compat",
"@phpstan",
"@test"
]
},
"scripts-descriptions": {
"test": "Run all tests",
"test:unit": "Run unit tests only",
"test:feature": "Run feature tests only",
"test:coverage": "Run tests with HTML coverage report (output to coverage/)",
"test:coverage-text": "Run tests with text coverage report",
"compat": "Check PHP 8.3-8.5 compatibility (syntax/functions)",
"compat:summary": "Check PHP compatibility (summary only)",
"compat:full": "Check PHP compatibility (detailed with error codes)",
"phpstan": "Run PHPStan static analysis (catches type errors)",
"phpstan:baseline": "Generate PHPStan baseline for existing issues",
"static": "Alias for phpstan",
"lint": "Full check: compatibility + static analysis + tests",
"check": "Quick check: compatibility summary + tests",
"ci": "CI pipeline: full compatibility + static analysis + tests"
}
}
Loading