# Upgrading to major version 2.0

**The LokiCheckout packages were initially (mid-2024 to mid-2025) developed with a namespace `Yireo\LokiCheckout\`. However, because the LokiCheckout becomes more and more an entity separate from the company Yireo, it was decided to rename things drastically - mainly to drop the *Yireo* prefix.**

The major renaming of PHP namespaces, composer packages and Magento modules was a change that changed almost every single file. This has led - following semantic versioning - to major versions for the various packages, except for the packages still full in developent (`@dev` or `0.0.*`). For instance, the main package `yireo/magento2-loki-checkout-core` was renamed to `loki-checkout/magento2-core` which bumped the version from 1.X to 2.0. This document outlines the various steps to take in upgrading a Magento instance.

> It might sound weird but the upgrade of various packages from 1.X to 2.0 is unrelated to the schedule of milestones. Packages adhere to semantic versioning. The milestones are meant for project management.

> This major renaming took place as part of milestone 1.2.

## List of changes with major 2.0
- The module `yireo/magento2-loki-checkout` (`Yireo_LokiCheckout`) was renamed to `loki-checkout/magento2-core` (`LokiCheckout_Core`);
- All remaining modules starting with `yireo/magento2-loki-checkout-*` (`Yireo_LokiCheckout*`) were renamed to `loki-checkout/magento2-*` (`LokiCheckout_*`);
- The functionality of backend pages and the CLI has been moved from the main core package to separate packages: `loki-checkout/magento2-core-adminhtml` (`LokiCheckout_CoreAdminhtml`) and `loki-checkout/magento2-core-cli` (`LokiCheckout_CoreCli`);
- The module `yireo/magento2-loki-components-debugger` (`Yireo_LokiComponentsDebugger`) was renamed to `loki/magento2-debugger` (`Loki_Debugger`);
- All remaining modules starting with `yireo/magento2-loki-*` (`Yireo_Loki*`) were renamed to `loki/magento2-*` (`Loki_*`);
- All PHP namespaces starting with `Yireo\LokiCheckout\*` were renamed to `LokiCheckout\*`; 
- All PHP namespaces starting with `Yireo\LokiComponents\*` were renamed to `Loki\Components\*`; 
- All PHP namespaces starting with `Yireo\LokiFieldComponents\*` were renamed to `Loki\Field\*`; 
- All PHP namespaces starting with `Yireo\LokiMapComponents\*` were renamed to `Loki\Map\*`; 
- All free checkout modules have been moved from [github.com/yireo](https://github.com/yireo) to [github.com/LokiCheckout](https://github.com/LokiCheckout);
- All remaining free Loki modules have been moved from [github.com/yireo](https://github.com/yireo) to [github.com/LokiExtensions](https://github.com/LokiExtensions);
- All GitLab repositories have been renamed (both repository name and URL), following the new Magento module standard;

> Note that the change in PHP namespaces effects PHP class files, PHTML templates and XML files.

## What did not change
- Functionality;
- XML layout file names and block names;
- CSS definitions;

> If you are in doubt on how this effects your instance, do make sure to contact us. We are happy to setup a call.

## Upgrading composer packages
The upgrade of composer packages could take place via either the CLI or a manual editing of the `composer.json` file. When upgrading things from the CLI, it is almost best to simply remove the LokiCheckout packages and re-add them. This automatically takes care of all versioning as well.

## Upgrading composer packages via CLI
First dump all Loki packages to a temporary file:
```bash
composer show -N | grep loki > old-packages.txt
```

This file `old-packages.txt` might look something like the following:
```txt
yireo/magento2-loki-checkout
yireo/magento2-loki-checkout-mollie
yireo/magento2-loki-checkout-postcode-nl
yireo/magento2-loki-checkout-edit-cart
yireo/magento2-loki-checkout-customer-note
yireo/magento2-loki-components
yireo/magento2-loki-components-debugger
yireo/magento2-loki-field-components
```

Now, the packages need to be renamed, for instance by copying `old-packages.txt` to `new-packages.txt`. In the case of the packages above, the output of `new-packages.txt` is:

```txt
loki-checkout/magento2-core
loki-checkout/magento2-mollie
loki-checkout/magento2-postcode-nl
loki-checkout/magento2-edit-cart
loki-checkout/magento2-customer-note
loki/magento2-loki-components
loki/magento2-loki-debugger
loki/magento2-field-components
```

```bash
composer remove `cat old-packages.txt`
composer require `cat old-packages.txt`
```

## Upgrading composer packages via composer.json
Instead of using the commands above, you might as well just open up the `composer.json` file directly and make the changes there. However, note that composer replacements and dependency calculations might make things a bit more difficult. Because of this, we recommend you - after making the changes to `composer.json` - to remove the `vendor/` folder and `composer.lock` file and recalculate all versions and dependencies again.

```bash
rm -r vendor/ composer.lock
composer install
```

## Additional composer packages
The functionality of backend pages and the CLI has been moved from the main core package to separate packages. The backend pages are handy for troubleshooting, so we recommend installing this:

```bash
comopser require loki-checkout/magento2-core-adminhtml
```

The CLI package is - currently - only needed if you are using a Luma theme:
```bash
comopser require loki-checkout/magento2-core-cli
```

## Modifying `app/etc/config.php`
All modules related to the LokiCheckout need to renamed as well in the file `app/etc/config.php`.

The old contents might look like the following:
```php
<?php
return [
    'modules' => [
        ...
        'Yireo_LokiComponents' => 1,
        'Yireo_LokiFieldComponents' => 1,
        'Yireo_LokiMapComponents' => 1,
        'Yireo_LokiCheckout' => 1,
        ...
    ]
];
```

The new contents might look like the following:
```php
<?php
return [
    'modules' => [
        ...
        'Loki_Components' => 1,
        'Loki_FieldComponents' => 1,
        'Loki_MapComponents' => 1,
        'LokiCheckout_Core' => 1,
        'LokiCheckout_CoreAdminhtml' => 1,
        'LokiCheckout_CoreCli' => 1,
        ...
    ]
];
```

## Scanning for code changes
If you have created template overrides, XML layout enhancements or PHP code that hooks into the LokiCheckout, it is required to update that code as well. Commonly, this includes changes in the XML layout when it comes to Magento module names and/or PHP namespaces.

To detect code that needs updating, you might use the following command:
```bash
grep -ri yireo app/design/frontend/ | grep -i loki
```

## Refresh the cache and generated files
Flush the cache, preferably by flushing Redis (`redis-cli flushall`) or removing the `var/cache/` folder (or both).

Remove the `generated/` folder.

Next, run the following to make sure the database is properly upgraded as well:
```bash
bin/magento setup:upgrade
```

Finally, it is good to double-check that things are working in the Developer Mode:
```bash
bin/magento deploy:mode:set developer
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento deploy:mode:set developer
```

If this works in the Developer Mode, it probably works in the Production Mode as well.
