2026-12-04 05:16:52 +01:00
2026-12-04 01:56:05 +01:00

iriks-it/laravel-manager

A modular backend for Laravel sites. Install it, switch on the parts the site needs, done.

composer require iriks-it/laravel-manager
php artisan vendor:publish --tag=manager-config
php artisan migrate

Put IriksIT\Manager\Concerns\HasManagerAccess on the User model. The manager lives at /manager (MANAGER_PATH) behind the web and auth middleware (config/manager.php).

Set up with an AI agent

php artisan manager:install --modules=users,media,posts --user-model="App\Models\User"
php artisan manager:doctor --json   # non-zero exit when something is wrong; each problem has a `fix`

resources/ai/INTEGRATION.md is a step-by-step guide for an agent; resources/boost/guidelines/core.blade.php is picked up by Laravel Boost.

Screens and themes

The package brings its own screens (a small Vue app on the JSON routes, already built: your app needs no Node). They also give an app without a login a login and a profile. MANAGER_UI=none turns them off, for an app that builds its own screens on the JSON routes. A browser that opens a manager address gets the page; anything that asks for JSON gets the data.

  • Looks. Built in are dark and light. MANAGER_THEME is what everyone sees until they choose; with MANAGER_USER_THEMES=true (default) each account picks its own in its profile.
  • The house style of the site. php artisan manager:make-theme acme --brand=#e4002b --name="Acme" --logo=/img/logo.svg --font="Inter, sans-serif" writes resources/manager-themes/acme.json; set MANAGER_THEME=acme. A theme is colours, a radius, fonts, a name and a logo, and every value is checked, so a theme file can never put CSS or markup in the page. Themes can also be listed in manager.themes.
  • Not built yet: a theme editor in the manager (themes are files for now), and screens for modules your own site adds (they show a notice).
  • Working on the screens: the sources are in ui/; npm ci && npm run build there writes resources/dist, which is committed (PR CI fails when it is out of date).

Modules

Key What Default
users Accounts, groups and permissions on
media Media library on
pages Page texts on
posts Posts on
reviews Reviews off
audit Audit log and address bans off
statistics Visitor statistics off

Switch a part in config/manager.php (modules) or with MANAGER_PAGES, MANAGER_POSTS, MANAGER_REVIEWS, MANAGER_AUDIT, MANAGER_STATISTICS. A module that is off has no routes, no tables, no menu item and no permissions: its migrations are not loaded at all. A module that needs another one (requires()) fails at boot when that one is off.

Language

The texts the server makes (menu, permission and section labels, theme names, audit summaries and the messages of the JSON routes) go through Laravel's __() with the English text as the key. The package ships resources/lang/nl.json; the screens follow app()->getLocale(). A site translates more, or words things differently, with its own lang/<locale>.json: that file wins over the package. Audit lines are written in the language of the request that made them.

The menu and the simple view

A module's menu item is ['label' =>, 'route' =>, 'permission' =>] and may add section (a heading), icon (home, file, image, users, group, chart, shield, star, tag, link, cog), order (lower first, default 100), simple and new_tab. A site changes the menu without code in config/manager.php: menu.items by route name without the prefix ('posts.index' => ['order' => 10, 'section' => 'Content', 'hidden' => false]) and menu.links for items of its own (['label' => 'Leads', 'url' => '/manager/leads', 'permission' => null]).

simple_view (MANAGER_SIMPLE_VIEW=true) adds a simple face next to the full one, for an owner who only needs a few screens. Two permissions appear in the group form: manager.full (everything; super admins have it) and manager.switch (starts simple and may switch; the choice is remembered per account and the menu has a button for it). Every other account always gets the simple face: only the items marked simple. It limits the menu, not the access: the routes still check their own permissions. Turning it on makes accounts without manager.full or manager.switch see only the simple items, so give the groups what they need first.

A site with data and names of its own

The package never maps its queries onto other tables: every screen assumes its own columns. What it does give you is room to coexist and a way to move data in.

  • route_name (default manager): the prefix of the route names. A site that already has manager.* routes sets, for example, 'route_name' => 'cms'; the menu and the screens follow. Use IriksIT\Manager\Support\Names::route('posts.index') in code of your own.
  • table_prefix (default manager_) and tables (['media' => 'site_files']): the names of the tables. Set them before the first migrate; the package does not rename a table that exists.
  • php artisan manager:import posts --table=articles --map=title=headline --map=body=content [--dry-run] [--connection=...] [--limit=...] copies the rows of a table of the site into posts, pages or reviews. The source is only read, and running it again updates the rows it made (found by slug, or by author and text for reviews). --map is package_column=source_column. Put the settings in manager.import.<target> (table, connection, map) to run it without options. Tags may be JSON or a comma separated list; a row without the required text is skipped and reported.

Your own module

Implement IriksIT\Manager\Contracts\Module (or extend Modules\BaseModule), keep routes.php and a migrations/ folder next to the class, and add the class to available in the config.

Users module

Accounts and groups. HasManagerAccess on the host User model gives it managerGroups(), managerPermissions(), hasManagerPermission(), managerOutranks() and managerMayGive(). Keep is_super_admin out of $fillable: nobody becomes a super admin through a form.

php artisan manager:create-user      # the only way to make a super admin
  • A group is a name plus permissions; a permission that needs another one (posts.publish needs posts.write) brings it along. Permissions of a module that is off are ignored.
  • Whoever manages accounts only touches accounts that need nothing more than their own rights, and only hands out groups that give nothing they lack themselves.
  • groups.manage is a gate for super admins only, not a permission of a group.
  • The package defines one gate per permission and no Gate::before: it never answers for the abilities of your own app.
  • The migration adds is_super_admin to your users table (the table of manager.user_model). It promotes nobody.

Media module

Files live on a Laravel filesystem disk (manager.media.disk); each row remembers its own disk.

  • Manager (behind manager.middleware): GET /manager/media, /manager/media/items, POST, PUT /{id}, DELETE /{id}. Limits (total room, file size, extensions) are in manager.media.*.
  • Visitors: GET /media-files/{id}/{filename}/view, outside the manager, no session. ETag, byte ranges, nosniff, and only images, video and PDF are shown inline. Rate limiter media-files.
  • Where a file is used: other modules or your app register a source with app(IriksIT\Manager\Support\MediaUsage::class)->register(fn () => $texts). Posts and Pages do.
  • No SVG: it can carry scripts.

Posts module

Posts written in Markdown, with drafts, scheduling, categories and tags.

  • Routes under /manager: posts (list, create, {id}/edit, {id}/preview, update, {id}/online, delete) and labels (categories and tags: make, rename, merge, remove). Rights: posts.view, write, publish, delete, labels.
  • Who may not publish only saves drafts, and cannot change or delete a post that is live or scheduled.
  • A post is a draft (published_at null), scheduled (in the future) or published. For your public pages: IriksIT\Manager\Models\Post::published(), toCard() and IriksIT\Manager\Support\Markdown::toHtml() (raw HTML is escaped, external links open in a new window). The package has no public post routes: the host decides what a visitor sees.
  • Categories offered in the form: manager.posts.categories, the ones in use, the ones made by hand and whatever your site adds with app(IriksIT\Manager\Modules\Posts\PostLabels::class)->suggestCategories(fn () => $titles).
  • Covers and bodies count as use of a media file.

Audit module

Off by default: it stores IP addresses and browser lines, so a site switches it on knowingly and says so in its privacy policy (MANAGER_AUDIT=true).

  • The log: logins, logouts and failed logins (from Laravel's own Login, Logout and Failed events, so it works with any login the host has), every change in the manager, every page that is opened (not twice within five minutes) and every refusal. Only the account, the address and the browser line are kept, and for an action the fields its module listed, never what was typed into a form. The log is read with audit.view.
  • Names: a module says what its routes are called in the log with actions() and views(); a test fails on a manager route without a name.
  • Bans (audit.manage): ban an address by hand, for a time or until lifted, or a whole group of addresses (notes put addresses in a group). After too many failed logins an address is banned by itself (the rules are set in the manager). A banned address gets a 403 (429 for an automatic ban) on every manager route. Put the manager.not-banned middleware on the login routes of your app too. A site that is locked out lifts the ban with php artisan manager:unban {ip}.
  • Behind a proxy: set up trusted proxies (or MANAGER_NEVER_BAN) before switching the module on. Without them every visitor shares one address, and one bad actor can lock the whole manager out. Failed logins on any guard count towards the automatic ban.
  • Whole-site bans: with MANAGER_AUDIT_WHOLE_SITE_BANS=true a ban can also keep an address off the whole app. That adds a global middleware that is answered from the cache.
  • Config (manager.audit): never_ban (MANAGER_NEVER_BAN, comma-separated: your own addresses), and max_keep_days (MANAGER_AUDIT_MAX_KEEP_DAYS, 90): the longest the log may be kept, which your privacy policy has to agree with. manager:audit-prune runs daily and deletes old lines and ended bans; notes stay until removed.

Statistics module

Off by default (MANAGER_STATISTICS=true). The site's own visitor statistics, with no cookie and no stored IP address: a visitor is a code made of the address, the browser and a random key that is deleted after a day (manager:forget-visitor-keys, scheduled daily), so a code cannot be traced back afterwards. A browser that sends DNT or Sec-GPC is not counted.

  • Reporting: the pages of your site POST to /pulse/view ({path, referrer, via, campaign}, answers {token}) and, when the visitor leaves, /pulse/leave ({token, seconds}). No session, rate limited (manager.statistics.per_minute).
  • Which pages count: only addresses you name, so nobody can fill the statistics with made-up ones: manager.statistics.pages, the posts under manager.statistics.posts_path (published ones only), and anything else through app(IriksIT\Manager\Modules\Statistics\CountedPages::class)->register(fn (string $path) => ...).
  • Programs: the pages served to search engines, crawlers and previews are counted per day, program and page (no address, no browser line), by a middleware the module adds to the web group (manager.statistics.count_bots).
  • The report (statistics.view): visitors, visits, page views, time, bounce rate, a comparison with another period, pages, posts, sources and channels, devices, heatmap, programs; GET /manager/statistics?range=30d and a CSV per sheet (/manager/statistics/export?sheet=days|pages|sources|bots).
  • Country only when manager.statistics.country_header names a header (Cloudflare: CF-IPCountry).

State of this version

Done: module registry and switches, permissions per module, users (accounts, groups, command), media (library and public file route), posts (with categories and tags), the audit log with bans, the statistics, the built-in screens for all of these (with a login and profile), themes, and the install and doctor commands for AI agents. composer test runs the tests.

Pages and reviews are still skeletons (a read-only list), and revisions are not ported yet. The answers of every action are JSON in the shape the screens use, so an app can build its own screens with MANAGER_UI=none.

Development cycle

develop ── feature/*, fix/* ──► release/vX.Y.Z ──► production ──► tag vX.Y.Z ──► Packagist
   ▲        (pull request,        (collects the      (pull request,                  │
   │         merges by itself)     features)          merged by hand)                │
   └──────────────────────── sync: production into develop ◄─────────────────────────┘
  1. Start a release: Actions → Start release → version (0.2.0). That makes release/v0.2.0 from develop.
  2. Features: branch feature/… or fix/… from develop, open a pull request to the release branch. It merges by itself when PR CI is green. Every pull request adds its row to TOKENS.md.
  3. Ready: add a section ## v0.2.0 - date to CHANGELOG.md and open a pull request from the release branch to production. A person merges it.
  4. Release (automatic, on the merge): tests and audit once more, the tag v0.2.0 and a Gitea release with the changelog text, Packagist is told, and production is merged into develop.

Nobody opens a pull request to develop, and production and the release branches take no direct pushes.

When What runs
Pull request to a release branch or to production flow (right branches, version above the latest tag, changelog section, tests of these scripts), ledger (TOKENS.md), test (Pint, Pest with the newest and the oldest dependencies, composer validate), security (composer audit, Trivy on the dependencies, secrets and settings). The check PR CI / pr-ci is green when all are.
Push to production verify (Pest, audit), tag and release, Packagist, sync develop
Every Monday composer audit and Trivy on production
Every Monday Dependency updates: a direct dependency with a release outside its constraint (a new major) gets its constraint widened in a pull request renovate/deps-DATE to the open release branch; the npm packages of the screens (ui/) move to their newest release that has been public for 48 hours, with a rebuilt resources/dist, in renovate/ui-deps-DATE. PR CI tests them and they merge when green. Nothing happens while no release is open. The central Trivy (every night 03:00 UTC) and Renovate (04:00 UTC) of the homelab also pass over this repo, but read a composer.lock and a package has none, so they find little here.
Every night Prune branches: removes feature/* and fix/* branches whose last commit is over 30 days old and that have no open pull request (a branch of a pull request can be restored from it in Gitea)

Secrets of the repository for this: DEPLOY_TOKEN (the organisation has it), and PACKAGIST_USERNAME and PACKAGIST_TOKEN (until they are set that step only says so). When Packagist does not know the package yet, that step submits it through the create-package API; after that it only tells Packagist about each new tag.

What Composer installs

.gitattributes leaves what only belongs to the repository out of the package (export-ignore): .gitea/, dev/, scripts/, tests/, TOKENS.md, AGENTS.md, phpunit.xml and the dotfiles. They stay in the repository. Packagist builds the archive from git archive, so what a site installs is src/, config/, routes/, resources/, composer.json, README.md and CHANGELOG.md. Check it with git archive HEAD | tar -t.

S
Description
Tags only, for Packagist: the releases of iriks-it/laravel-manager. No development happens here.
Readme
1,007 KiB
0 Stars 10 Watchers 0 Forks