Reviewed-on: #6
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).
Modules
| Key | What | Default |
|---|---|---|
users |
Accounts, groups and permissions | on |
media |
Media library | on |
pages |
Page texts | on |
posts |
Posts | on |
reviews |
Reviews | off |
Switch a part in config/manager.php (modules) or with MANAGER_PAGES, MANAGER_POSTS,
MANAGER_REVIEWS. 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.
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.publishneedsposts.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.manageis 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_adminto your users table (the table ofmanager.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 inmanager.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 limitermedia-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) andlabels(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_atnull), scheduled (in the future) or published. For your public pages:IriksIT\Manager\Models\Post::published(),toCard()andIriksIT\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 withapp(IriksIT\Manager\Modules\Posts\PostLabels::class)->suggestCategories(fn () => $titles). - Covers and bodies count as use of a media file.
State of this version
Done: module registry and switches, permissions per module, users (accounts, groups, command), media
(library and public file route) and posts (with categories and tags), 59 tests (composer test).
The answers of every action are JSON, in the shape the screens of bouwbedrijf.iriks-it.nl got as
Inertia props. The screens themselves are not in the package yet: the frontend is an open decision
(AGENTS.md). Pages and reviews are still skeletons (a list), and login, profile, the audit log and revisions are not
ported yet.
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 ◄─────────────────────────┘
- Start a release: Actions → Start release → version (
0.2.0). That makesrelease/v0.2.0fromdevelop. - Features: branch
feature/…orfix/…fromdevelop, open a pull request to the release branch. It merges by itself when PR CI is green. Every pull request adds its row toTOKENS.md. - Ready: add a section
## v0.2.0 - datetoCHANGELOG.mdand open a pull request from the release branch toproduction. A person merges it. - Release (automatic, on the merge): tests and audit once more, the tag
v0.2.0and a Gitea release with the changelog text, Packagist is told, andproductionis merged intodevelop.
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 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 once the package is submitted on packagist.org (until then that step only says so).
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.