Skip to content

Latest commit

 

History

History
148 lines (130 loc) · 8.74 KB

upgrade-instructions-for-symfony-flex.md

File metadata and controls

148 lines (130 loc) · 8.74 KB

Upgrade Instructions for Symfony Flex

In #1492 we changed the application to be compatible with Symfony Flex. You can read more about upgrading Symfony application to Flex https://symfony.com/doc/current/setup/flex.html

  • copy .env and .env.test files from GitHub into the root folder
  • add local environment files as ignored into .gitignore
    /docker-compose.yml
    /docker-sync.yml
+   /.env.local
+   /.env.local.php
+   /.env.*.local
  • copy symfony.lock file from GitHub into the root folder

  • copy composer.json file from GitHub into the root folder

    • add any project-specific dependencies
  • in easy-coding-standard.yml replace

    • */tests/ShopBundle/ with */tests/App/
    • */src/Shopsys/ShopBundle/ with */src/
  • in .eslintignore remove Shopsys/ShopBundle from all paths

  • replace phpunit.xml with phpunit.xml version from GitHub

  • replace phpstan.neon with phpstan.neon version from GitHub

    • add any project-specific configurations
  • replace build/codeception.yml with build/codeception.yml version from GitHub

  • move the original source code from src/Shopsys/ShopBundle/ to src/ and update the namespaces of every PHP file to be App\... (advanced IDEs can do this automatically)

  • remove bundle related files as the application itself is no longer a bundle

    • src/Shopsys/ShopBundle/ShopsysShopBundle.php
    • src/Shopsys/ShopBundle/DependencyInjection/Configuration.php
    • src/Shopsys/ShopBundle/DependencyInjection/ShopsysShopExtension.php
  • update application bootstrapping:

  • all configuration files are now located in the config folder exclusively

    • copy all config files to your project from the config folder from the new version
    • merge your project-specific configurations from app/config and src/Shopsys/ShopBundle/resources/config folders into config. Keep in mind, that
      • config.yml, config_dev.yml, and config_test.yml should be deleted as they're no longer necessary
      • in parameters_common.yaml all extended entities in shopsys.entity_extension.map have to have new namespace App\...
      • some paths in paths.yaml have changed, so be extra careful when changing with your modifications
      • routing files (routing.yml, routing_dev.yml, and routing_test.yml) are no longer necessary
      • any project-specific routes have to be moved into routes, routes/dev, or routes/test folders into a separate file
      • any project-specific form extensions have to be added into config/forms.yaml
      • any project-specific image configurations have to be added into config/images.yaml
      • any project-specific cron definitions have to be added into config/services/cron.yaml
  • move templates from src/Shopsys/ShopBundle/Resources/views/ to templates/ folder

  • remove @ShopsysShop Twig namespace in every template, eg.

    -   {% extends '@ShopsysShop/Front/Layout/base.html.twig' %}
    -   {% use '@ShopsysShop/Front/Layout/header.html.twig' %}
    +   {% extends 'Front/Layout/base.html.twig' %}
    +   {% use 'Front/Layout/header.html.twig' %}
  • remove @ShopsysShop Twig namespace from render methods in controllers, eg.

    -   return $this->render('@ShopsysShop/Front/Content/Article/menu.html.twig', [
    +   return $this->render('Front/Content/Article/menu.html.twig', [
            'articles' => $articles,
        ]);
  • change rendering of embedded controllers in templates from three-part notation to standard string syntax for controllers, eg.

    -   {{ render(controller('ShopsysShopBundle:Front/Heureka:embedWidget')) }}
    +   {{ render(controller('App\\Controller\\Front\\HeurekaController:embedWidgetAction')) }}
    • Tip: you can use regular expression search for ShopsysShopBundle:Front/(\w+):(\w+) and replace with App\\Controller\\Front\\$1Controller:$2Action in Twig files
  • update constant in templates/Front/Content/Product/filterFormMacro.html.twig

        {% if isSearch %}
            <input
                type="hidden"
    -           name="{{ constant('Shopsys\\ShopBundle\\Controller\\Front\\ProductController::SEARCH_TEXT_PARAMETER') }}"
    +           name="{{ constant('App\\Controller\\Front\\ProductController::SEARCH_TEXT_PARAMETER') }}"
  • change redirect/forward calls in controllers from three-part notation to fully qualified name, eg.

    -   return $this->forward('ShopsysShopBundle:Front/FlashMessage:index');
    +   return $this->forward(FlashMessageController::class . ':indexAction');
  • move overridden bundle templates from app/Resources/views/ to templates/bundle (see more about template overriding https://symfony.com/doc/current/bundles/override.html#templates)

  • move translation files from src/Shopsys/ShopBundle/Resources/translations/ to translations/

  • move rest of a files from src/Shopsys/ShopBundle/Resources/ to src/Resources/

  • update Grunt template directory in templates/Grunt/gruntfile.js.twig (2 occurrences)

        destHtml: 'docs/generated',
        htmlDemo: true,
    -   htmlDemoTemplate: '{{ customResourcesDirectory|raw }}/views/Grunt/htmlDocumentTemplate.html',
    +   htmlDemoTemplate: '{{ gruntTemplateDirectory|raw }}/htmlDocumentTemplate.html',
        htmlDemoFilename: 'webfont-admin-svg',
  • update config file paths from app/config to config in following files any others you may have create

    • .ci/build_kubernetes.sh
    • .ci/deploy-to-google-cloud.sh
    • scripts/install.sh
    • kubernetes/kustomize/base/kustomization.yaml
  • change namespaces in migrations-lock.yml file from Shopsys\ShopBundle\... to App\..., eg.

        20191114101504:
    -       class: Shopsys\ShopBundle\Migrations\Version20191114101504
    +       class: App\Migrations\Version20191114101504
            skip: false
  • move tests from tests/ShopBundle/ to tests/App/ and update the namespaces of every PHP file to be Tests\App\... (advanced IDEs can do this automatically)

  • change namespace from Tests\ShopBundle\... to Tests\App\... in following files

    • tests/App/Acceptance/acceptance.suite.yml
    • tests/App/Functional/Component/Javascript/Compiler/Constant/JsConstantCompilerPassTest.php
    • tests/App/Functional/Component/Javascript/Compiler/Constant/testClassName.expected.js
    • tests/App/Functional/Component/Javascript/Compiler/Constant/testClassName.js
    • tests/App/Functional/Component/Javascript/Compiler/Constant/testDefinedConstant.js
    • tests/App/Functional/Component/Javascript/Compiler/Constant/testUndefinedConstant.js
  • update tests/App/Test/Codeception/Helper/SymfonyHelper.php with the new Kernel class

    -   use AppKernel;
    +   use App\Kernel;
        use Codeception\Configuration;
        use Codeception\Module;
    
        ...
    
            {
                require_once Configuration::projectDir() . '/../app/autoload.php';
    
    -           $this->kernel = new AppKernel(EnvironmentType::TEST, EnvironmentType::isDebug(EnvironmentType::TEST));
    +           $this->kernel = new Kernel(EnvironmentType::TEST, EnvironmentType::isDebug(EnvironmentType::TEST));
                $this->kernel->boot();
            }
  • change namespace from Shopsys/ShopBundle to App in constants in following JS files and any others you created

    • src/Resources/scripts/frontend/cart/cartRecalculator.js
    • src/Resources/scripts/frontend/validation/form/customer.js
    • src/Resources/scripts/frontend/validation/form/order.js
    • src/Resources/scripts/frontend/promoCode.js
  • run composer update