Search by

filagora / filagora-cms

zcwilt

Pages, blocks, navigations, media and a draft, version, schedule and preview workflow for Filagora.

Package info

github.com/filagora/filagora-cms

pkg:composer/filagora/filagora-cms

Statistics

Installs: 826

Dependents: 1

Suggesters: 1

Stars: 0

Open Issues: 0

v0.4.2 2026-11-28 18:22 UTC

This package is auto-updated.

Last update: 2026-11-28 18:22:59 UTC


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 between 0.x minor 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 so php artisan filagora:adopt can 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_assets and cms_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's type is 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 core SchemaExtension.

  • 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 under cms:navigation:{name} for navigation_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 the PreviewResolver contract (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) with NavigationLinkTypes::register(), giving a resolver from the item's reference to 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 how MediaAssetUsage tells 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: PageVersioning snapshots a page; restoreVersionToDraft loads one into the draft without touching live content; isStale says the page was published since the draft began.
    • Schedule: schedule, cancelSchedule and publishDue, run by php 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: previewPage and previewPageVariant build an unsaved in-memory copy as it would look once published.
    • PageDraftDiff describes 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 a CmsNavigationPublished event, restore a version to the draft, schedule, and itemsForVariant to read the items of any variant. NavigationDraftDiff lists 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-due publishes due pages and menus.

  • The same for reusable blocks (BlockDrafts): a hidden staged copy, pending-change check, publish with a version and a CmsBlockPublished event, 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=TOKEN shows the draft menus and pages that preview link names, and /privacy without the parameter is always the live page. No session or cookie is used, so the two can be compared in two tabs. PreviewSession is the PreviewResolver the 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 to landingPage() with PreviewUrl::with()); revoke() ends a link, and so does expiry, at the next request.
    • PreviewUrl::with($url, $token) puts the token into an address.
    • CarryPreviewToken keeps 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 a data-preview-skip attribute (use it for a banner's "view the live page" link); list path prefixes to skip, such as the staff area, in filagora-cms.preview.carry_token_except. Switch it off with preview.carry_token.
    • MarkPreviewResponsesUncacheable marks every response to a request with a token no-store, private, noindex, nofollow and Referrer-Policy: no-referrer. Both middleware are added to the web group unless switched off in config.
    • items() describes what is being previewed (for a banner), token() and expiresAt() give the token and when it lapses. The parameter's name is filagora-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.
  • Search (with filagora/filagora-search installed). 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.manage and filagora.cms.preview, mapped to entitlements in filagora-cms.gates.

  • Filament screens (FilagoraCmsPlugin, in a "Content" navigation group; every screen needs filagora.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 in media.accepted are 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 PageUrlResolver contract (default: the custom route or /pages/{slug}); the address of a shared link from the route named in filagora-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 of BlockType. 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.