Upgrading from 0.2 to 0.3
simply-framework 0.3 moves to Symfony 7.4, rebuilds the cache reliably and makes the hooks declared with attributes lazy. It goes with simply-maker 0.4, simply-mvc 0.3 and the boilerplate 0.7. Read the release notes for the full list.
1. Composer constraints of your project
In the root composer.json (created from the boilerplate):
"clementdecou/simply-framework": "^0.3",
"clementdecou/simply-maker": "^0.4",
"clementdecou/simply-mvc": "^0.3",
"symfony/dotenv": "^7.4"
(simply-mvc only if you use it), then:
composer update -W
Any other package of the project that requires Symfony 6 blocks the update. WordPress plugins that bundle an unscoped copy of Symfony load the same classes as Simply: check them as well.
2. Your code extending Symfony classes
- Console commands (in your plugins and theme): replace
protected static $defaultNamewith the#[AsCommand]attribute, and declareexecute(): int. Simply maker registers every command it finds: a single command without a name breaks the wholebin/console.use Symfony\Component\Console\Attribute\AsCommand;use Symfony\Component\Console\Command\Command;use Symfony\Component\Console\Input\InputInterface;use Symfony\Component\Console\Output\OutputInterface;#[AsCommand(name: 'app:import', description: 'Import the products.')]class ImportCommand extends Command{protected function execute(InputInterface $input, OutputInterface $output): int{return Command::SUCCESS;}} - Configuration classes: declare
getConfigTreeBuilder(): TreeBuilder, otherwise the container build fails. ContainerAwareInterfaceandContainerAwareTraitno longer exist: inject the services you need.ServiceSubscriberTraitis deprecated: useServiceMethodsSubscriberTrait(see hooks).- See Symfony's UPGRADE-7.0 for the other changes.
3. Hooks declared with attributes
- The service is instantiated the first time WordPress runs one of its hooks, no longer on every request.
- The WordPress callback is a
LazyHookListener, no longer[$service, 'method']:remove_action()andhas_filter()with[$service, 'method']no longer find these hooks. See unhooking an attribute hook. - The build fails with an explicit message when a method with
#[Action]or#[Filter]is not public, or takes a parameter by reference. - Removed:
Simply\Core\Compiler\HookCompiler,setCallable()andregister()on theActionandFilterattributes (which no longer implementHookableInterface), thesimply.compile_hooksparameter. TheHookManagerconstructor changed.
4. Cache
The cache now lives in a sub-directory per fingerprint, and the compiled container class is CachedContainer_<fingerprint>. There is nothing to clear for the upgrade itself: the new package versions change the fingerprint.
The Redis cache now stores the values set without expiration (it stored nothing before 0.3.1): pass an expiration or delete the keys if your code relied on it.
5. Boilerplate configuration
If you copy the new config/application.php of the boilerplate:
DB_PREFIX,DB_NAME,DB_USERandDB_PASSWORDmust be defined;DISABLE_WP_CRON=falsenow really enables the cron;APP_DEBUGacceptstrue,1,onandyes;WP_SITEURLdefaults toWP_HOME/wp.
See configuration.
6. Check
On a staging environment, run php bin/console list and load a few pages before deploying.