- Updated Dockerfile configurations for various environments (alpine, basic, cloudrun, minimal, simple, test) to ensure compatibility with Laravel 5.0 and PHP 5.6. - Added PHP compatibility documentation outlining mcrypt requirements and upgrade paths. - Created cloudbuild.yaml for Google Cloud Build integration to streamline deployment to Cloud Run. - Introduced docker-compose.local.yml for local development with MySQL and Redis services. - Enhanced rebuild.sh script for easier local development and migration handling. - Updated Laravel Blade views to correct asset paths. - Added start-local.sh script for quick local setup and service management.
2.2 KiB
2.2 KiB
Laravel 5.0 and PHP Compatibility Guide
Issue: mcrypt Extension Required
Laravel 5.0 requires the mcrypt PHP extension, which was:
- Deprecated in PHP 7.1
- Removed in PHP 7.2+
Solutions
Option 1: Use PHP 5.6 (Current Implementation)
The Dockerfile.minimal has been updated to use PHP 5.6 which is the ideal match for Laravel 5.0.
Pros:
- Perfect compatibility with Laravel 5.0
- Native mcrypt support
- All packages available and tested
- Matches original development environment
Cons:
- PHP 5.6 reached end-of-life in December 2018
- Security concerns for long-term production use
Option 2: Upgrade Laravel (Recommended for Production)
Upgrade to Laravel 5.5+ which doesn't require mcrypt.
# Update composer.json
"laravel/framework": "5.8.*"
# Remove mcrypt dependencies and update encryption
php artisan key:generate
Option 3: Use OpenSSL Instead (Laravel 5.2+)
If upgrading Laravel, update encryption configuration:
// config/app.php
'cipher' => 'AES-256-CBC',
Current Docker Configuration
The Dockerfile now uses:
- Base Image:
php:5.6-apache - mcrypt Extension: Native support (no installation issues)
- Other Extensions: All Laravel 5.0 requirements met
- Package Compatibility: Perfect match for PHP 5.6
Production Recommendations
For a production deployment, consider:
- Upgrade Laravel to 5.8 or later (LTS)
- Use PHP 7.4+ for better performance and security
- Replace mcrypt with OpenSSL encryption
Quick Upgrade Path (Optional)
If you want to modernize the application:
Step 1: Update composer.json
{
"require": {
"laravel/framework": "5.8.*"
}
}
Step 2: Update Dockerfile to use PHP 7.4
FROM php:7.4-apache
# Remove mcrypt installation
Step 3: Update configuration
php artisan key:generate
php artisan config:cache
Security Note
Since PHP 7.1 is end-of-life, monitor for security updates and consider upgrading the Laravel version for long-term production use.
Testing the Current Setup
The current configuration should work with:
./start-local.sh
This will use PHP 7.1 with mcrypt support for Laravel 5.0 compatibility.