Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/coverage/admin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
99.87% of lines, 7 not covered
99.88% of lines, 7 not covered
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ All notable changes are listed here. The format follows [Keep a Changelog](https
- Every source file starts with the Atrium copyright header. Pint adds it to PHP (`header_comment` in pint.json), `php scripts/copyright-header.php --fix` to Blade, Vue, JS, CSS, shell and YAML, and `tests/Unit/CopyrightHeaderTest.php` fails without it.
- Docs module (`alveby/atrium-docs`): documentation pages made from the Markdown of a repository, the README, `docs/`, the changelog and every package's README, at `/docs/{version}/{page}` and `/{lang}/docs/…`. A sidebar, a contents list, GitHub's heading anchors, code coloured on the server by Phiki with light and dark themes at 4.5:1 or more, search in the language of the page with suggestions as you type, "Edit this page on GitHub". A page without a translation is shown in English with a notice, its canonical pointing to the English page and its hreflang listing only real translations. `atrium:docs:pull v0.2.0` copies a release out of git as one more version; the newest release is the default and older ones say so. Interface in 15 languages.
- Module settings: a module names a `settings` class in its manifest (`extra.atrium.settings`), extending `Atrium\Admin\Modules\ModuleSettings`, with fields of the admin's own types, their rules and defaults, for all sites or for each (`$perSite`). The panel gets a **Modules** screen listing the installed modules and a settings screen for each; the `{key}.settings` permission is in the module's row of the role form. Values are read with `Setting::get('shop.currency')` (the current site's value, else the field's default) and kept in `admin_module_settings`. The manifest may set the module's `key` and `title`. The catalog has the first one: products on a page of a section, per site.
- Record cache: public pages stay fast with dozens of properties, relations, pictures and translations per record. A model that `implements Cacheable` and `use CachesRecords` gets a card per record, a plain cached array built from its admin fields (every language, the relations of its link fields, SEO, pictures with thumbnails, the public URL, and what extenders add). `Model::cached($id)` and `Model::cachedMany($ids)` read cards in one multi-get and build the missing ones together in a few queries. Lists ask only for IDs: `->cachedIds()` keeps the IDs and the total of a page under a hash of the SQL, the page, the site and the language, `->cachedPaginate()` and `->cachedCards()` return cards; `RecordCache::remember()` keeps any other value under the models it reads. Catalog, news, pages, brands, stores, FAQ and reviews read through it, and the theme keeps its ready record view in the card. A save, delete or restore through Eloquent drops the record's cards in every site and language and the cards of same-model records that show it, and bumps a version counter for its lists and for cards that depend on the model, so the admin's change is on the site at once; `bulk()` drops once at the end of an import (the Bitrix commands drop everything once). Works on every Laravel store: tags on Redis and Memcached, version keys on the file and database stores; Redis is recommended. Module settings are kept in it too. The `atrium.cache.stats` filter gives monitoring the hits and misses of the finished request. On a warm cache a list or product page runs no query.
- Page cache for visitors without a login (`ATRIUM_PAGE_CACHE=true`, off by default): whole pages keyed by the URL and the site, never for a signed-in admin, the CSRF token swapped for the visitor's on the way out, dropped by the same saves as the cards; `ETag`, `Last-Modified`, `304` and `Cache-Control` with `s-maxage` for a CDN (`private` when the page holds a form token).
- `atrium:cache:warm` opens the home page and the first page of every list of every site and language (`--records` also builds every card). **Admin → Cache** shows the hit rate, the store and its size, and clears one module, one site or everything. In local mode with `APP_DEBUG` a line under public pages and an `X-Atrium-Debug` header count queries and cache hits.
- A cache benchmark (`ATRIUM_BENCHMARK=1 vendor/bin/phpunit packages/theme/tests/CacheBenchmarkTest.php`): 10 000 products with 40 properties, list and product pages with the cache off, cold, warm and with the page cache. Guide: [docs/cache.md](docs/cache.md).
- AI module (`alveby/atrium-ai`, on the Laravel AI SDK): a **Generate** link under text fields marked `->ai()` writes a description, a preview, the SEO title, description and keywords, or a picture's alt text, and **Translate** fills a translatable field's other languages. The text is offered in a dialog to edit or drop; nothing is saved until the editor saves. The SEO fields of `HasAdminSeo` have it already. Providers come in chains per kind of work (text, vision, embeddings) with fallback on a limit or a timeout; the defaults are free tiers (Gemini, Groq, OpenRouter) or a local Ollama, keys only from `.env`, and no key means no buttons. The provider is called after the response or by a queue worker, so the form never waits; prompts are Blade views; `ai_usage` logs task, provider, tokens and time without the texts; `atrium:ai:status` shows the chains and the usage. The same over `POST /api/v1/ai/generate` and the `generate_text` MCP tool. A module adds its own MCP tools through `atrium.mcp.tools`.
- The AI module's helper: the Atrium arch in the corner of every admin page, animated, opens a chat that answers in the administrator's language from the guides and the module READMEs, and reads the records of the modules the administrator may view (tools `list_modules`, `describe_module`, `list_records`, `get_record`, `search_docs`), with links into the admin. It only reads. Other packages add tools in `atrium-ai.help.tools`; `ATRIUM_AI_HELP=false` turns it off. Interface in 15 languages.
- `DisplayField`: read-only HTML on the edit form, drawn from the record by the server (`->html(fn (Model $record): string => …)`), for order lines, summaries and links. It is not on the create form and nothing is taken from the request for it.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ The Bitrix database is only read. The tabs, field order and list columns come ou
- [SEO: titles, hreflang, sitemaps, schema.org, redirects, the SEO check](docs/seo.md)
- [Your own module: fields, columns, tabs, permissions, languages, tests, a package](docs/modules.md)
- [Custom fields: add fields to any module from the admin, filters and facets on 100 000 records](docs/custom-fields.md)
- [Cache: fast pages with dozens of properties, Redis, the page cache, CDN headers](docs/cache.md)
- [Moving from 1C-Bitrix, step by step](docs/bitrix.md)
- [Backups: databases and files to several places, schedules, health checks, restore](docs/backup.md)
- [CDN: pictures, resized copies and WebP/AVIF, cache purge, uploads to S3](docs/cdn.md)
Expand Down
53 changes: 53 additions & 0 deletions config/atrium.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Atrium\Admin\Dashboard\Gadgets\PerformanceGadget;
use Atrium\Admin\Dashboard\Gadgets\SiteSpeedGadget;
use Atrium\Admin\Models\AdminUser;
use Atrium\Admin\Models\PageTiming;

return [
/*
Expand Down Expand Up @@ -209,6 +210,11 @@
'route' => 'admin.api-tokens.index',
'icon' => 'settings',
],
[
'label' => 'atrium::menu.cache',
'route' => 'admin.cache.index',
'icon' => 'settings',
],
],

/*
Expand Down Expand Up @@ -441,4 +447,51 @@
'enabled' => (bool) env('ATRIUM_MCP_ENABLED', true),
'path' => 'mcp',
],

/*
|--------------------------------------------------------------------------
| Cache
|--------------------------------------------------------------------------
|
| The record cache (docs/cache.md): lists answer with ids, records come
| from cards built once per language, and saving a record in the admin
| drops what showed it. Works on every Laravel store; Redis is the one to
| use in production (one MGET per list, tags free memory at once).
|
| store a store of config/cache.php, the default one when null
| strategy auto: tags where the store has them (Redis, Memcached),
| version keys elsewhere; versions: version keys everywhere
| ttl seconds: cards, lists of ids, full pages
| time_step lists that compare with "now" (active from/to) see time in
| steps of this many seconds, so their keys stay the same
| ignore models whose saves never touch the cache
| pages full-page cache for visitors who are not logged in to the
| admin; off by default (see docs/cache.md before turning on)
| debug a line under public pages with queries and cache hits, in
| the local environment with APP_DEBUG on
|
*/
'cache' => [
'enabled' => (bool) env('ATRIUM_CACHE_ENABLED', true),
'store' => env('ATRIUM_CACHE_STORE'),
'strategy' => env('ATRIUM_CACHE_STRATEGY', 'auto'),
'ttl' => [
'cards' => (int) env('ATRIUM_CACHE_TTL_CARDS', 86400),
'lists' => (int) env('ATRIUM_CACHE_TTL_LISTS', 3600),
'pages' => (int) env('ATRIUM_CACHE_TTL_PAGES', 600),
],
'time_step' => 60,
'stats' => true,
'ignore' => [
PageTiming::class,
],
'pages' => [
'enabled' => (bool) env('ATRIUM_PAGE_CACHE', false),
// Seconds a CDN may keep a page without the session's form token.
'shared_max_age' => (int) env('ATRIUM_PAGE_CACHE_SHARED_MAX_AGE', 60),
// Paths never cached, as Request::is() patterns.
'except' => [],
],
'debug' => (bool) env('ATRIUM_CACHE_DEBUG', true),
],
];
Loading
Loading