Upgrading to Grav 1.8 beta
Caution
NOTICE: This is a work in progress, it may contain content that is not in sync with latest released versions of Grav 1.7 or 1.8 beta
Grav 1.8 introduces significant improvements including PHP 8.3 requirement, updated dependencies, and a new safe upgrade system. Here are a few highlights:
- PHP 8.3+ Requirement: Major update from PHP 7.3 requirement in Grav 1.7
- Safe Upgrade System: Comprehensive preflight checks, staging, validation, and rollback capabilities
- Enhanced Twig Support: Updated to Twig 3.x (forked version for Defer compatibility)
- Symfony 7 Integration: Upgraded to Symfony 7.x components for better performance and security
- Improved Caching: Symfony Cache provider replaces Doctrine Cache (deprecated)
- Monolog Compatibility: Switched to Monolog 3, but retains support for Monolog 2.3+ syntax
- Code Quality: PHPStan level 6 support and PHP 8.4 compatibility fixes
Tip
IMPORTANT: Grav 1.8 requires PHP 8.3 or later version. This is a major change from Grav 1.7's PHP 7.3.6+ requirement. Always take a backup of your site and test the upgrade in a testing environment before upgrading your live site, or use 'safe-upgrade' which automatically creates a restorable snapshot of Grav core.
Most Common Issues
-
PHP 8.3 Compatibility Issues
Issue: Custom plugins/themes using deprecated PHP features fail to work Solution: Update code to be PHP 8.3 compatible
- Check for nullable parameter declarations
- Update dynamic properties usage
- Replace deprecated functions
-
Cache Driver Errors
Issue: Site breaks after upgrade due to removed cache drivers Solution:
- Grav 1.8 automatically maps Doctrine cache adapters (
apcu,memcached,redis,array, etc.) to their Symfony Cache equivalents during upgrade. - If Grav encounters an adapter it cannot map, it falls back to the default
filesystemcache to keep the site running. - Update your
system.yamlcache configuration to the desired adapter for clarity:YAMLsystem: cache: driver: apcu # instead of apc # or driver: memcached # instead of memcache
- Grav 1.8 automatically maps Doctrine cache adapters (
-
Monolog Logging Issues
Issue: Custom logging code may break with Monolog 2.3/3.x Solution: Update logging calls:
PHP// Old $this->grav['log']->addInfo($message); $this->grav['log']->addError($message); ... // New (compatible with both Monolog 2.x and 3.x) $this->grav['log']->info($message); $this->grav['log']->error($message); ... -
PSR-3 Logging Conflicts
Issue: Plugins or themes that ship their own
vendor/folder orcomposer.jsonand pinpsr/logto an older 1.x release force Composer to install an incompatible version. This breaks Grav's Monolog 3 handler expectations and triggers errors likeReturn type must be compatible with Psr\Log\LoggerInterface. Solution:- Remove the explicit
psr/logrequirement from your extension, or - Prefer Grav's bundled version by adding a
replaceblock to yourcomposer.json:JSON"replace": { "psr/log": "*" } - Delete the plugin's
vendor/directory after updatingcomposer.jsonand rebuild it withcomposer install.
The
bin/gpm preflightcommand surfaces this issue under PSR/log compatibility warnings, resolve them before upgrading. - Remove the explicit
-
Missing Settings Configuration
Issue: Errors due to removed
system.umask_fixsetting Solution: Remove this setting from yoursystem.yamlas it's been removed for security reasons
Quick Update Guide
Caution
Grav 1.8 requires PHP 8.3 or later version. The recommended version is the latest PHP 8.4 release.
Critical Breaking Changes
PHP Version Requirement
- Minimum PHP: 8.3+ (was 7.3.6+ in Grav 1.7)
- Ensure your hosting environment supports PHP 8.3 or higher
- Update any deprecated PHP code in custom plugins/themes
Removed Cache Drivers
The following unsupported cache drivers have been removed. Supported adapters (APCu, Memcached, Redis, Array, Filesystem, etc.) are handled by Symfony Cache with the same names, and Grav falls back to filesystem if it cannot resolve a custom adapter:
APC(useapcuinstead)WinCacheXCacheMemcache(usememcachedinstead)
Removed Settings
system.umask_fixsetting removed for security reasons
Safe Upgrade System
Grav 1.8 introduces a comprehensive safe upgrade system:
Preflight Checks
Run compatibility checks before upgrading:
bin/grav preflight
The preflight command checks for:
- Plugins pending updates
- PSR-3 logging conflicts
- Monolog version conflicts
- Other compatibility issues
Automated Safe Upgrades
The new upgrade system includes:
- Staging: Creates snapshots before upgrading
- Validation: Verifies upgrade integrity
- Rollback: Automatic recovery if upgrade fails
Recovery Mode
- Token-gated recovery UI
- Plugin quarantine system
- CLI rollback support
Enhanced Twig Support
- Updated to Twig 3.x (forked version for PHP 8.4 compatibility)
- New
strict_mode.twig2_compatandstrict_mode.twig3_compatsettings - Deferred Extension support for Twig 1.x compatibility
- Twig Sandbox security improvements
Manual Twig 3 Updates
The compatibility toggles rewrite a handful of Twig 1/2 constructs on the fly, but you should update templates permanently to avoid runtime transforms.
-
Loop guards: Replace legacy
forloops with inlineifguards ({% for page in collection if page.published %}) by filtering the sequence first.TWIG{# Legacy #} {% for page in collection if page.published %} {{ page.title }} {% endfor %} {# Twig 3 friendly #} {% for page in collection|filter(page => page.published) %} {{ page.title }} {% endfor %} -
spacelessandfilterblocks: Twig 3 removed{% spaceless %}and{% filter %}blocks; switch them to{% apply %}.TWIG{# Legacy #} {% spaceless %} <div>{{ content|raw }}</div> {% endspaceless %} {# Twig 3 #} {% apply spaceless %} <div>{{ content|raw }}</div> {% endapply %} sameastest: Useis same asinstead ofis sameas.TWIG{% if theme is same as('my-theme') %}replacefilter signature: Twig 3 expects a map instead of two string arguments.TWIG{{ title|replace({'_': ' '}) }}
After fixing templates, disable system.strict_mode.twig2_compat and system.strict_mode.twig3_compat and clear the cache to confirm everything renders without the compatibility layer.
Symfony 7 Integration
- Upgraded to Symfony 7.x components
- Symfony Cache provider (replaces Doctrine Cache)
- Better performance and security
Dependency Updates
Core Dependencies
- PHP: 8.3+ (was 7.3.6+)
- Twig: 3.x (forked for Defer compatibility)
- Symfony: 7.x (was 4.4)
- Monolog: 3.x (was 1.25)
- RocketTheme/Toolbox: 2.0 (was 1.0)
Removed Dependencies
- Doctrine Cache (replaced with Symfony Cache)
- Legacy cache drivers (APC, WinCache, XCache, Memcache)
Configuration Changes
New Settings
system:
strict_mode:
twig2_compat: true # Enable Twig 2 compatibility mode
twig3_compat: true # Enable Twig 3 compatibility mode
Updated Defaults
- Cache drivers changed to use Symfony Cache
- Security settings tightened
Developer Changes
Code Quality Improvements
- PHPStan level 6 support in Framework classes
- PHP 8.4 compatibility fixes
- Better type declarations
- Improved error handling
API Changes
- Updated event system
- Enhanced logging interface
- Improved caching abstractions
Plugin & Theme Compatibility
Required Updates
- Plugins must support PHP 8.3+
- Update logging calls for Monolog compatibility
- Replace deprecated function calls
- Test with Symfony 6.4/7.x components
Testing Checklist
- [ ] Plugin loads without errors
- [ ] Admin interface works correctly
- [ ] Forms process properly
- [ ] Media uploads function
- [ ] Caching works as expected
Upgrade Process
Pre-Upgrade Checklist
- Backup your site - Always backup before upgrading
- Check PHP version - Ensure PHP 8.3+ is available
- Run preflight check -
bin/grav preflight - Update custom code - Fix PHP 8.3 compatibility issues
- Test in staging - Never upgrade production directly
Upgrade Methods
Method 1: Safe Upgrade (Recommended)
# Perform Grav safe upgrade
bin/gpm self-upgrade --safe
# Monitor for any issues
bin/grav logviewer
Method 2: Legacy Manual Upgrade w/manual backup
# Backup first
bin/grav backup
# Run manual preflight checks
bin/gpm preflight
# Update all packages
bin/gpm update -f
# Update Grav with old upgrade system
bin/gpm self-upgrade --legacy
Post-Upgrade Steps
- Verify site functionality
- Check admin panel
- Test forms and user interactions
- Review error logs
- Update plugin configurations if needed
Troubleshooting
Common Issues
Cache Errors After Upgrade
# Clear all cache
bin/grav clear-cache --all
# Check cache configuration
cat user/config/system.yaml | grep -A 5 cache:
Logging Issues
# Check log permissions
ls -la logs/
# Test logging
bin/grav log --level=debug
Plugin Compatibility
# List all plugins
bin/plugin list
# Check for updates
bin/gpm update --list-only
Recovery Procedures
Using Recovery Mode
- Access
/recoveryURL with recovery token - Quarantine problematic plugins
- Rollback to previous version if needed
CLI Recovery
# Recovery with prompt to pick from latest snapshots
bin/restore
# List snapshots
bin/restore list
# Rollback to previous snapshot version
bin/restore apply <version>
# Command Help
bin/restore -h
# Get recovery status
bin/restore recovery status
# Clear recovery status
bin/restore recovery clear
Additional Changelog Callouts
- Safe upgrade snapshots: Early Grav 1.8 betas (pre
1.8.0-beta.10) could miss dotfiles during safe upgrades. If you upgraded with those builds, double-check your project root for files such as.htaccessand re-run the latest safe-upgrade flow if anything is missing. - CLI script permissions: A fix in
1.8.0-beta.16restores executable permissions on thebin/*scripts after upgrades. If CLI tools stop working (permission denied), runchmod +x bin/*to align with the expected state. - YamlUpdater API tweaks:
1.8.0-beta.5throughbeta.7introduced new publicYamlUpdater::get(),set(), andexists()helpers. Update any automation or plugins that interact with YAML updates to call these methods instead of relying on private internals.
Getting Help
Resources
Support Information
When reporting issues, include:
- PHP version
- Grav version (before and after upgrade)
- Preflight command output
- Error logs
- List of installed plugins
Migration from Development
If upgrading a development site:
- Update local PHP to 8.3+
- Update composer dependencies
- Run automated tests
- Update CI/CD pipelines
- Deploy to staging before production
⚠️ Important: Always test upgrades in a staging environment before applying to production. The new safe upgrade system provides rollback capabilities, but prevention is better than recovery.