Troubleshooting
Common issues and solutions when working with Stilmark Base.
Installation Issues
Composer Installation Fails
Problem: composer require stilmark/base
fails with dependency conflicts.
Solution:
# Update Composer first
composer self-update
# Clear Composer cache
composer clear-cache
# Try installation with verbose output
composer require stilmark/base -v
PHP Version Compatibility
Problem: "Your PHP version (X.X.X) does not satisfy requirement php ^8.2"
Solution:
Ensure you're running PHP 8.2 or higher
Check your PHP version:
php -v
Update PHP through your system package manager or use a version manager like phpbrew
Missing Extensions
Problem: Class 'Symfony\Component\Dotenv\Dotenv' not found or OAuth functionality not working.
Solution:
# Install required PHP extensions
sudo apt-get install php8.2-json php8.2-curl # Ubuntu/Debian
brew install php@8.2 # macOS with Homebrew
# Verify extensions are loaded
php -m | grep -E "(json|curl)"
Runtime Issues
Environment Variables Not Loading
Problem: Env::get()
returns null or default values.
Solutions:
Check
.env
file exists and is readableVerify file path in
Env::load()
callEnsure no syntax errors in
.env
file
// Debug environment loading
use Stilmark\Base\Env;
if (!file_exists('.env')) {
echo "Error: .env file not found\n";
}
Env::load('.env');
var_dump(Env::get('APP_ENV')); // Should not be null
Routing Issues
Problem: Routes not matching or 404 errors.
Solutions:
Check route definitions syntax
Verify controller namespace and method exist
Ensure proper URL rewriting (Apache/Nginx)
// Debug routing
$router = new Router();
$router->addRoute('GET', '/debug', function() {
return 'Route working!';
});
OAuth Authentication Fails
Problem: Google OAuth returns errors or fails silently.
Solutions:
Verify Google OAuth credentials in
.env
Check redirect URI matches Google Console settings
Ensure HTTPS in production
# Required .env variables
GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_client_secret
GOOGLE_REDIRECT_URI=https://yourdomain.com/auth/google/callback
Session Issues
Problem: Sessions not persisting or authentication middleware failing.
Solutions:
Ensure sessions are started before using Auth
Check session configuration
Verify session storage permissions
// Start sessions before using Auth
session_start();
// Check session configuration
var_dump(session_get_cookie_params());
Performance Issues
Slow Route Resolution
Problem: Application responds slowly on route matching.
Solutions:
Enable route caching in production
Optimize route definitions order
Use FastRoute's caching features
// Enable route caching
$router = new Router();
$router->setCacheFile('/path/to/cache/routes.cache');
Memory Usage
Problem: High memory consumption.
Solutions:
Profile memory usage with Xdebug
Optimize large data processing
Use streaming for large responses
Development Tips
Debugging
Enable detailed error reporting during development:
// In your bootstrap file
if (Env::get('APP_ENV') === 'development') {
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('log_errors', 1);
}
Logging
Use the built-in Logger for debugging:
use Stilmark\Base\Logger;
$logger = new Logger();
$logger->info('Debug message', ['context' => $data]);
Testing Routes
Create a simple test script:
<?php
require 'vendor/autoload.php';
use Stilmark\Base\Router;
$router = new Router();
$router->addRoute('GET', '/test', function() {
return 'Test successful!';
});
// Simulate a request
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/test';
$router->dispatch();
Getting Help
If you're still experiencing issues:
Check the GitHub Issues
Review the complete documentation
Create a minimal reproduction case
Submit a new issue with:
PHP version
Stilmark Base version
Error messages
Minimal code example
Last updated