-
the interface
Monofony\Contracts\Api\Identifier\AppUserIdentifierNormalizerInterface
has been changed due to Symfony changes.Before
public function denormalize($data, $type, $format = null, array $context = []); public function supportsDenormalization($data, $type, $format = null);
After
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed; public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool;
-
Twig 3 does not support spaceless tag anymore
Before
{% spaceless %} <-- .... --> {% endspaceless %}
After
{% apply spaceless %} <-- .... --> {% endapply %}
-
Annotations are not supported anymore on Symfony 7
on
App\Message\ChangeAppUserPassword
Before
/** * @SecurityAssert\UserPassword(message="sylius.user.plainPassword.wrong_current") */
After
#[SecurityAssert\UserPassword(message: 'sylius.user.plainPassword.wrong_current')]
on
App\Message\RegisterAppUser
Before
/** * @CustomConstraints\UniqueAppUserEmail() */
After
#[CustomConstraints\UniqueAppUserEmail]
Before
/** * @Vich\UploadableField(mapping="admin_avatar", fileNameProperty="path") */
After
#[Vich\UploadableField(mapping: 'admin_avatar', fileNameProperty: 'path')]
-
Symfony\Component\Security\Core\Security
has been removed from SymfonyReplace by
Symfony\Bundle\SecurityBundle\Security
-
Symfony\Component\Messenger\Handler\MessageHandlerInterface
interface has been removedBefore
final class RegisterAppUserHandler implements MessageHandlerInterface
After
#[AsMessageHandler] final class RegisterAppUserHandler
-
Use new AsCommand attribute on your commands
Before
class InstallAssetsCommand extends Command { protected static $defaultName = 'app:install:assets'; // ... protected function configure(): void { $this->setDescription('Installs all AppName assets.'); } // ... }
After
#[AsCommand( name: 'app:install:assets', description: 'Installs all AppName assets.', )] class InstallAssetsCommand extends Command { // ... }
-
Doctrine Event subscribers have been removed
Before
final class CanonicalizerSubscriber implements EventSubscriber { // ... public function getSubscribedEvents(): array { return [ Events::prePersist, Events::preUpdate, ]; } }
After
[AsDoctrineListener(event: Events::prePersist)] final class CanonicalizerSubscriber { // ...
Add these lines on config/packages/monofony_admin.yaml
imports:
- { resource: '@SyliusUiBundle/Resources/config/app/config.yml' }
On config/packages/security.yaml
Replace
security:
firewalls:
admin:
# [...]
anonymous: true
api:
# [...]
anonymous: true
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator
with
security:
# Add this line
enable_authenticator_manager: true
# [...]
firewalls:
admin:
# [...]
# Remove that line
# anonymous: true
api:
# [...]
entry_point: jwt
jwt: true
refresh_jwt:
check_path: /api/token/refresh
And replace IS_AUTHENTICATED_ANONYMOUSLY
with PUBLIC_ACCESS
Update controller on routes' configuration with two dots:
Example:
_controller: App\Controller\DashboardController:indexAction
replaced by _controller: App\Controller\DashboardController::indexAction
On config/routes/api.yaml
Replace
gesdinet_jwt_refresh_token:
path: /api/token/refresh
controller: gesdinet.jwtrefreshtoken::refresh
With
api_refresh_token:
path: /api/token/refresh
On config/packages/test/framework.yaml
Replace
framework:
test: ~
session:
storage_id: session.storage.mock_file
With
framework:
test: ~
session:
storage_factory_id: session.storage.factory.mock_file
On config/packages/test/monofony_core.yaml
Replace
swiftmailer:
spool:
type: file
path: "%kernel.cache_dir%/spool"
With
framework:
cache:
pools:
test.mailer_pool:
adapter: cache.adapter.filesystem
on src/EventSubscriber/CanonicalaizerSubscriber.php
Replace
} elseif ($item instanceof UserInterface) {
With
} elseif ($item instanceof UserInterface && method_exists($item, 'getUsername')) {
on src/EventSubscriber/DefaultUsernameORMSubscriber.php
Replace
if ($customer->getEmail() === $user->getUsername() && $customer->getEmailCanonical() === $user->getUsernameCanonical()) {
continue;
}
With
if (!method_exists($user, 'getUsername')) {
continue;
}
if ($customer->getEmail() === $user->getUsername() && $customer->getEmailCanonical() === $user->getUsernameCanonical()) {
continue;
}
on src/Security/UserChecker.php
Replace
if (!$user instanceof User) {
return;
}
With
if (!$user instanceof AdvancedUserInterface || !method_exists($user, 'isCredentialsNonExpired')
return;
}
And add this line on imports
use SyliusLabs\Polyfill\Symfony\Security\Core\User\AdvancedUserInterface;
First use composer 2 using these commands:
composer self-update
composer self -v
Ensure you requires Symfony 4.4.*:
composer config extra.symfony.require "4.4.*"
Ensure you use stable releases:
composer config minimum-stability "stable"
Update your dependencies:
composer remove \
monofony/api-bundle \
monofony/front-bundle \
monofony/admin-bundle \
monofony/core-bundle \
monofony/fixtures-plugin \
--no-update --no-scripts --no-plugins
composer require \
php:^7.3 \
monofony/core-pack \
monofony/api-pack \
monofony/admin-pack \
monofony/front-pack \
symfony/dotenv:4.4.* \
symfony/flex:^1.9 \
symfony/monolog-bundle:^3.1 \
symfony/webpack-encore-bundle:^1.7 \
--no-update --no-scripts --no-plugins
composer require --dev monofony/test-pack:^0.4 --no-update --no-scripts --no-plugins
composer require \
eightpoints/guzzle-bundle:^7.3 \
sensio/framework-extra-bundle:^5.1 \
sensiolabs/security-checker:^5.0 \
sylius/mailer-bundle \
twig/extensions \
--no-update --no-scripts --no-plugins
Copy the script to migrate the code:
php -r "copy('https://raw.githubusercontent.com/Monofony/Monofony/0.x/bin/upgrade-to-0.4', 'bin/upgrade-to-0.4');"
Make it executuable:
chmod a+x bin/upgrade-to-0.4
Run it:
bin/upgrade-to-0.4
And finally run composer update:
composer update