filagora / filagora-cms
Pages, blocks, navigations, media and a draft, version, schedule and preview workflow for Filagora.
Requires
- php: ^8.4
- filagora/filagora-core: ^0.2.1
- filament/filament: ^5.0
Requires (Dev)
- filagora/filagora-entitlements: ^0.2.1
- filagora/filagora-search: ^0.1.1
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
Suggests
- filagora/filagora-entitlements: Answers the access checks from entitlement grants and lets the menu editor pick entitlement keys. Without it, bind Filagora\Core\Contracts\AccessChecker.
- filagora/filagora-search: Adds page search with a choice of engine: Meilisearch, or the database.
Provides
None
Conflicts
None
Replaces
None
README
Pages, content blocks, menus, tags and media for Filagora, with a staged-edit workflow (drafts,
named variants, versions, scheduled publishing and previews), as a Laravel 13 / Filament 5 plugin.
Requires filagora/filagora-core. Who may use the
editor, and which menu items a visitor sees, is answered by core's AccessChecker: install
filagora/filagora-entitlements and it is
answered from entitlement grants, or bind your own checker (roles, policies, a permissions
package). With neither, the editor denies everyone.
The package is at
0.2: the API may change between0.xminor versions. There is no frontend: it is models, services, events and staff screens, and you render the pages.
What it provides
Overview
Pages, blocks, navigations, media and a draft, version, schedule and preview workflow for Filagora.
Tables
cms_pages, cms_blocks, cms_block_versions, cms_page_versions, cms_page_drafts, cms_page_draft_variants, cms_navigations, cms_navigation_versions, cms_navigation_drafts, cms_navigation_draft_variants, cms_tags, cms_page_tag, cms_media_assets, cms_preview_shares, prefixed filagora_ by default. A site that already has them can run php artisan filagora:adopt instead of migrating.
Commands
| Command | What it does |
|---|---|
filagora:cms:publish-due |
Publish CMS page and menu drafts whose scheduled publish time has arrived. |
Events
CmsBlockPublished: A reusable block's staged copy was applied to the live block and a version recorded.CmsNavigationPublished: A menu draft was applied to the live menu and a version recorded.CmsPagePublished: A page draft was applied to the live page and a version recorded.
Access
| Ability | Entitlement key |
|---|---|
filagora.cms.manage |
filagora.cms.manage |
filagora.cms.preview |
filagora.cms.preview |
Using it
-
Fourteen tables, prefixed
filagora_by default, matching an existing site's tables index for index sophp artisan filagora:adoptcan accept them:cms_pages,cms_blocks,cms_block_versions,cms_page_versions,cms_page_drafts,cms_page_draft_variants,cms_navigations,cms_navigation_versions,cms_navigation_drafts,cms_navigation_draft_variants,cms_tags,cms_page_tag,cms_media_assetsandcms_preview_shares. -
Models for each (the tag pivot has none), swappable under
filagora.models.<key>. A page keeps its custom route as/x, is stamped with a publication time when it becomes published, and is public once that time has arrived (CmsPage::published()). Staged copies of blocks are hidden from every live read. A block'stypeis a free string, so a type the site no longer knows still loads. Saving a menu clears its cached items. -
A schema snapshot for
filagora:adopt. A site's own extra columns are declared with a coreSchemaExtension. -
Readers (
CmsContent): published pages (newest first, optionally by tag), a page by slug or by custom route (a draft page is served only to its preview token), menus, a published reusable block by slug, and media assets by path. Menus are cached undercms:navigation:{name}fornavigation_cache_seconds(default 300) and cleared when a menu is saved.navigationTitle($name)gives a menu's optional heading (a footer column's "Legal"), or null so the site can use its own. A request that is previewing unpublished changes is served those, through thePreviewResolvercontract (the default previews nothing). -
Menu items for a visitor (
NavigationItems): unknown link kinds become plain URLs, URLs are limited to relative paths and http(s), targets to_self,_blank,_parent,_top, items the visitor lacks the entitlements for are dropped, and so are empty placeholders. A site registers its own link kinds (a legal page, a named page of the application, an action such as logout) withNavigationLinkTypes::register(), giving a resolver from the item'sreferenceto a URL. -
Block types (
BlockTypeRegistry): nineteen generic types ship (raw HTML, hero, image, gallery, card grid, feature list, embed, divider, call-to-action band, stat strip, link grid, logo grid, accordion, icon callout, icon card grid, split info panel, checklist callout, comparison matrix and panel). A site registers its own and aliases for old keys. A stored type nobody knows still loads and is labelled as unknown. Each type says where its media asset ids sit in the block data, which is howMediaAssetUsagetells which live blocks use an asset. -
The staged-edit workflow for pages (
PageDrafts). Edits go into a working draft (the page fields, its tags, and a staged copy of each block) and reach live content only on publish.- Variants: a page has one working draft; others are parked beside it. Start a variant from the current draft or from live, switch, rename and delete them. Names are unique within a page, ignoring case. A draft with a schedule cannot be switched away from.
- Publish applies the fields, tags and blocks (edited, added and removed) in one transaction,
refuses a slug or custom route another page uses, records a numbered version and dispatches
CmsPagePublished.PageDrafts::isPublishing()is true meanwhile, so listeners that react to every saved row can wait for the event. - Versions:
PageVersioningsnapshots a page;restoreVersionToDraftloads one into the draft without touching live content;isStalesays the page was published since the draft began. - Schedule:
schedule,cancelScheduleandpublishDue, run byphp artisan filagora:cms:publish-due(schedule it every minute). A draft that can no longer publish has its schedule cleared and the problem reported; the rest still go out. - Preview:
previewPageandpreviewPageVariantbuild an unsaved in-memory copy as it would look once published. PageDraftDiffdescribes what publishing would change, field by field, tags and blocks.
-
The same for menus (
NavigationDrafts): one working draft of a menu's items, named variants, discard, stale check, publish (saving the menu clears its cache) with a version of the menu's name and items and aCmsNavigationPublishedevent, restore a version to the draft, schedule, anditemsForVariantto read the items of any variant.NavigationDraftDifflists items added, changed and removed, matched by label path ("Support › Donate"). A menu's name is an identifier the site relies on, so it is never staged.filagora:cms:publish-duepublishes due pages and menus. -
The same for reusable blocks (
BlockDrafts): a hidden staged copy, pending-change check, publish with a version and aCmsBlockPublishedevent, restore from a version.
These services do not check who may call them; the Filament screens do.
-
Previews. A preview is carried by the address and nothing else:
/privacy?preview=TOKENshows the draft menus and pages that preview link names, and/privacywithout the parameter is always the live page. No session or cookie is used, so the two can be compared in two tabs.PreviewSessionis thePreviewResolverthe readers use; it reads the token from the request.- A link names each menu and page either as a draft variant (pinned, so it does not change
when an editor switches the working draft) or as the working draft as it is now.
PreviewShares::create()bundles chosen menus and pages at named variants, with an expiry in days and a label;workingDraft()makes (or reuses) an editor's link to the working draft of menus and pages, valid for a day, which is what a Preview button should use. Tokens are long, random and never serialised.open($token)counts a visit and returns the share (send the visitor tolandingPage()withPreviewUrl::with());revoke()ends a link, and so does expiry, at the next request. PreviewUrl::with($url, $token)puts the token into an address.CarryPreviewTokenkeeps the token on links to other pages of the site and on redirects within it, so a draft menu can be followed from page to page. Links to other sites, in-page anchors and files are left alone, and so is an anchor with adata-preview-skipattribute (use it for a banner's "view the live page" link); list path prefixes to skip, such as the staff area, infilagora-cms.preview.carry_token_except. Switch it off withpreview.carry_token.MarkPreviewResponsesUncacheablemarks every response to a request with a tokenno-store, private,noindex, nofollowandReferrer-Policy: no-referrer. Both middleware are added to thewebgroup unless switched off in config.items()describes what is being previewed (for a banner),token()andexpiresAt()give the token and when it lapses. The parameter's name isfilagora-cms.preview.query_parameter.- Tokens in an address reach server logs, browser history and anything copied: keep links short-lived, keep an edge cache from storing any request that has the parameter, and keep the parameter out of access logs.
- The routes, the controllers and the banner are yours: this package has no frontend.
- A link names each menu and page either as a draft variant (pinned, so it does not change
when an editor switches the working draft) or as the working draft as it is now.
-
Search (with
filagora/filagora-searchinstalled). Published pages become a search index (title, excerpt, SEO fields, slug and the text of their live, published blocks, with tags removed and links left out).CmsSearch::pages($text, $page)returns the pages that are live now, from whichever engine the search package is set to (Meilisearch, or the database), and drops any hit whose row is no longer live because an index can be stale. Saving or deleting a live block keeps its page's document right. The search page is yours. -
Two abilities,
filagora.cms.manageandfilagora.cms.preview, mapped to entitlements infilagora-cms.gates. -
Filament screens (
FilagoraCmsPlugin, in a "Content" navigation group; every screen needsfilagora.cms.manage):- Pages: list with a state badge and filter; create; an editor that works on the draft ("Save draft"), with header actions for variants (switch, new, rename, delete), a shared preview link, preview, publish (with a version summary and a stale-draft warning), schedule, cancel schedule, discard draft and unpublish; a pending-changes panel from the diff; a staged-blocks table (add, edit, delete, with change badges); and a versions list (view the snapshot, restore to draft, delete). Each block type has its own form (see below); a type with no fields, or one nobody registered, falls back to a JSON editor and can still be edited.
- Menus: the same workflow, with a nested link editor (three levels) whose link kinds come
from
NavigationLinkTypes. - Tags, Media (single and bulk upload into
cms-media, details read from the file, usage count, delete with a warning when a block still uses it; only the types inmedia.acceptedare taken, stored under a tidied form of their name that never replaces another file) and Preview links (status, opens, show link, revoke). - The page URL the editor's Preview sends you to comes from the
PageUrlResolvercontract (default: the custom route or/pages/{slug}); the address of a shared link from the route named infilagora-cms.preview.share_route. Both are yours to provide. - Reusable blocks: list (type filter, pending-changes badge), create, an editor that works on the staged copy (slug changes apply at once), publish, discard, delete, and a versions list.
- Block forms: each of the 19 generic types declares fields with a small DSL
(
Field::text(),url(),textarea(),markdown(),select(),toggle(),number(),strings(),items(),media()), passed as the fifth argument ofBlockType. One definition drives the form, normalises what is saved, upgrades older stored shapes and derives the media paths (so usage tracking follows). A profile package registers its own types the same way.
Still to come
Nothing planned for this package beyond release.
Requirements
PHP 8.4, Laravel 13 and Filament 5. Tested against MariaDB 11.4. Requires filagora/filagora-core.
Install
composer require filagora/filagora-cms
php artisan migrate
php artisan filagora:entitlements:sync # only with entitlements installed
->plugin(\Filagora\Cms\FilagoraCmsPlugin::make())
Schedule filagora:cms:publish-due every minute to publish scheduled pages, menus and blocks.
Implement PageUrlResolver if your pages are not served at /pages/{slug}. Publish the config
with --tag=filagora-cms-config and the editor text with --tag=filagora-cms-lang.
Configuration
config/filagora-cms.php is merged with the host's copy, so list only what
differs. Publish it with php artisan vendor:publish --tag=filagora-cms-config.
Extending
Extend through documented contracts, events and registries. Anything not documented
is @internal.
Testing
composer test
Tests run against a real MariaDB, never SQLite, so engine behaviour (FULLTEXT,
ONLY_FULL_GROUP_BY, collation) matches production. Host and credentials come from
your environment; the database is always named testing, never your development one.
Local development (DDEV)
.ddev/ is included. ddev start creates both db and testing (run ddev restart once
if testing is missing), then ddev exec vendor/bin/pest.
Licence
MIT. See LICENSE.