# loki/magento2-base

> Base utilities for any Loki behaviour

`composer require loki/magento2-base`

Canonical URL: https://packagento.com/loki/magento2-base

## At a glance

- **Vendor**: Loki Extensions (https://packagento.com/loki.md)
- **Latest version**: 1.1.29 — released 2026-05-21
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/loki/magento2-base and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require loki/magento2-base:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Base utilities for any Loki behaviour

## README

**This Magento 2 module forms the base of various other Loki solutions: Loki Checkout, Loki Admin Components, Loki Theme for Luma. It adds Alpine.js to the page, adds container-blocks for other scripts to be added, it adds its own frontend messaging component and its adds an Alpine store for both localStorage and messaging.**

Most likely you do not install this module on its own, but require it through other modules.

### Installation
```bash
composer require loki/magento2-base
bin/magento module:enable Loki_Base
```

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [Unreleased]

### [1.1.29] - 21 May 2026
#### Fixed
- Make sure multiple calls to `refresh()` do not trigger multiple AJAX calls

### [1.1.28] - 08 May 2026
#### Fixed
- Fix bug in Alpine localStorage when it is out of sync

### [1.1.27] - 06 May 2026
#### Fixed
- Move data-child-name attribute to LokiCheckout_Core observer

### [1.1.26] - 06 May 2026
#### Fixed
- Add `data-child-name` attribute to blocks rendered via ChildRenderer

### [1.1.25] - 06 May 2026
#### Fixed
- Do not reset sortOrder because of other mechanisms using previous values
- Reset sortOrder of childRenderer to avoid negatives

### [1.1.24] - 28 March 2026
- Move TransferableAncestorBlockProperties from components to base

### [1.1.23] - 27 March 2026
#### Fixed
- Allow properties of ancestor block to populate child block

### [1.1.22] - 02 March 2026
#### Fixed
- Fix infinite loop and page freeze caused by async Alpine.effect
- Messages with timeout 0 were removed right away, instead of kept forever

### [1.1.21] - 25 February 2026
#### Fixed
- Make call to LocalStorage.get async

### [1.1.20] - 19 February 2026
#### Fixed
- Better way of rendering containers via ChildRenderer::all()
- Remove trailing slash from `customer/section/load` URL

### [1.1.19] - 16 February 2026
#### Fixed
- Make `Alpine.store('LocalStorage').get()` and `refresh()` asynchronous

### [1.1.18] - 12 February 2026
#### Fixed
- Allow PHP Config to read from current store level
- Allow filtering of child blocks by prefix
- Add ancestor block to children

### [1.1.17] - 23 January 2026
#### Fixed
- Prevent empty cookie from causing JS error

### [1.1.16] - 12 January 2026
#### Fixed
- Remove debugging console log
- Add new GitHub Action workflows
- Copy generic CI/CD files
- Copy generic CI/CD files

### [1.1.15] - 06 January 2026
#### Fixed
- Disable messages if `MageOS_AlpineMessages` is enabled

### [1.1.14] - 19 December 2025
#### Fixed
- Upgrade tests
- Cleanup duplicates in CHANGELOG

### [1.1.13] - 11 December 2025
#### Fixed
- Move dependency ComponentViewModelInterface from `Loki_Base` to `Loki_Components`

### [1.1.12] - 11 December 2025
#### Fixed
- Rename `LOKI_BASE_URL` to `BASE_URL`

### [1.1.11] - 21 November 2025
#### Fixed
- Add compatibility with `MageOS_AlpineLoader`
- Replace `$block->getChildHtml()` with `$childRenderer->all()` including better sorting
- Automatically sync localStorage.setItem to Alpine store

### [1.1.10] - 12 November 2025
#### Fixed
- Make sure component scripts are loaded after all other scripts

### [1.1.9] - 12 November 2025
#### Fixed
- Rename LokiMessageStore to Message
- Only load MageCookies if `MageOS_AlpineLocalStorage` is not enabled
- Fix wrong template variable
- Rename LokiLocalStorage to LocalStorage
- Check for duplicate `MageOS_AlpineLocalStorage`
- Move layout that is duplicate to Mage-OS Alpine to separate handles
- Remove temporarily Tailwind LESS attempt

### [1.1.8] - 03 November 2025
#### Fixed
- Change z-index for messages from 100 to 5
- Update composer keywords

### [1.1.7] - 22 October 2025
#### Fixed
- Do not escape `$css()` with `escapeHtmlAttr()` but `escapeHtml()`

### [1.1.6] - 09 October 2025
#### Fixed
- Adjust messages under Luma from z-index:300 to 100 to prevent clash with minicart

### [1.1.5] - 08 October 2025
#### Fixed
- Remove cookies by stripping all non-relevant cookie parts
- Change messages to position:sticky in Luma

### [1.1.4] - 07 October 2025
#### Fixed
- Allow for JS translations of dates

### [1.1.3] - 30 September 2025
#### Fixed
- Use new LOKI_THEME_URL variable in JS

### [1.1.2] - 30 September 2025
#### Fixed
- Remove block cache lifetime

### [1.1.1] - 29 September 2025
#### Fixed
- When removing cookies, ignore the domain-value

_(Changelog truncated for .md surface. Full history on https://packagento.com/loki/magento2-base.)_

## Recent Versions

| Version | Released |
|---|---|
| 1.1.29 | 2026-05-21 |
| 1.1.28 | 2026-05-08 |
| 1.1.27 | 2026-05-06 |
| 1.1.26 | 2026-05-06 |
| 1.1.25 | 2026-05-06 |
| 1.1.24 | 2026-03-28 |
| 1.1.23 | 2026-03-27 |
| 1.1.22 | 2026-03-02 |
| 1.1.21 | 2026-02-25 |
| 1.1.20 | 2026-02-19 |

Showing 10 of 35 versions. Full release history on https://packagento.com/loki/magento2-base.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| ext-pcre | * |
| loki/magento2-css-utils | ^1.0 |
| magento/framework | ^103.0 |
| magento/module-backend | ^102.0 |
| magento/module-store | ^101.0 |

## Quality

Latest release (1.1.29) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Warning | 9 | 9 warnings (ruleset: Magento2) — 2 auto-fixable with phpcbf |
| PHPMD | Pass | 0 |  |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 4 | 4 | – | – |
| 2.4.8 | – | 4 | 4 | – |
| 2.4.9 | – | – | 4 | 4 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | not tested | – |
| 2.4.9 | – | – | Pass | Pass |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["loki/magento2-base"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

Loki Extensions is a Magento 2 vendor on Packagento. See https://packagento.com/loki.md for their full catalogue.

