# iriks-it/laravel-manager A modular backend for Laravel sites. Install it, switch on the parts the site needs, done. ```bash 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 ```bash 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 | | `resources` | Lists defined in config (`manager.resources`) | on (nothing without definitions) | | `revisions` | History of posts and pages, with restore | on | | `sharing` | Share a published post on LinkedIn with one button (`manager.sharing`); a site adds other networks with a `Sharer` class. Rights `sharing.view`, `sharing.publish`, `sharing.manage` | off | | `updates` | What changed on the site: the releases of its `CHANGELOG.md` (`manager.updates`), right `updates.view` | off | Switch a part in `config/manager.php` (`modules`) or with `MANAGER_PAGES`, `MANAGER_POSTS`, `MANAGER_REVIEWS`, `MANAGER_AUDIT`, `MANAGER_STATISTICS`, `MANAGER_REVISIONS`, `MANAGER_UPDATES`, `MANAGER_SHARING`. A module that is off has **no routes, no tables, no menu item and no permissions**: | `costs` | What the work on the site cost, from its `TOKENS.md`, priced once and kept (`manager.costs`), right `costs.view` | off | | `numbers` | How the site is doing in plain words for an owner (needs `statistics`; uses `leads` when on), right `numbers.view` | off | | `updates` | What changed on the site: the releases of its `CHANGELOG.md` (`manager.updates`), right `updates.view` | off | Switch a part in `config/manager.php` (`modules`) or with `MANAGER_PAGES`, `MANAGER_POSTS`, `MANAGER_REVIEWS`, `MANAGER_AUDIT`, `MANAGER_STATISTICS`, `MANAGER_REVISIONS`, `MANAGER_UPDATES`, `MANAGER_COSTS`, `MANAGER_NUMBERS`. 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/.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. ## Your own lists and screens **Lists without code.** `manager.resources` turns a definition into a menu item, a list, a form, validation and the permissions `.view` and `.manage`, for things like a menu, socials, services, testimonials or leads: ```php 'resources' => [ 'services' => [ 'label' => 'Services', 'singular' => 'Service', 'model' => App\Models\Service::class, // the records live in a model of the site; leave it out to use the package's own table 'columns' => ['name', 'price'], 'order' => ['position', 'asc'], 'fields' => ['name' => ['type' => 'text', 'required' => true], 'price' => ['type' => 'number'], 'photo' => ['type' => 'media']], ], ], ``` **Ready-made lists.** `IriksIT\Manager\Support\Presets` has definitions for what a business site nearly always has: `services()`, `projects()`, `testimonials()`, `menu()` and `socials()`. Their field keys are the usual column names (`title`, `summary`, `is_active`, `sort_order`), so a site points `model` at its own table, or leaves it out to keep the records in the package's table. What the site passes wins, field by field: `'services' => Presets::services(['model' => Service::class, 'feature' => 'services', 'fields' => ['title' => ['label' => 'Name']]])`. `Presets::projects($override, serviceModel: Service::class)` adds the choice of a kind of work. `Presets::experience()` is work and projects for a CV (title, role, period, story, points, links, technology; `type` is `work` or `project` and the site may add kinds). `Presets::business()` is the page of business details (name, phone, address, registration numbers, opening hours, work area) for `manager.pages.definitions['business']`; read it with `Page::contentFor('business')`. The field keys are the attributes of the model (the definition is the whitelist: nothing else is written); without a model the values are kept as JSON in `manager_records`. Field types are the ones of the pages. Names that belong to a module (`posts`, `pages`, `media`, ...) are refused. **Screens of your own.** List a JavaScript module in `manager.extensions` (a path of your site, or https). The manager loads it before it shows anything and puts `window.IriksManager` in reach: `Vue`, `boot`, `api`, `t`, `flash`, `navigate`, `register` and the components `Link`, `FormFields`, `Icon` and `MediaPicker`. `register('^/leads$', Component, { data: true })` shows `Component` at `/manager/leads`, with the JSON of that same address (or of `source`) as props; an address of yours needs a route for the data, and a menu item through `manager.menu.links`. Build your bundle with `vue` left external (`build.rollupOptions.external: ['vue']`): the manager points `import 'vue'` at its own Vue, so your components share its reactivity. A browser that opens a manager address without a route of the package gets the screens (which show yours, or "no screen yet"); a request for data gets a plain 404. ## A site with data and names of its own The package never maps its queries onto other columns: every screen assumes its own columns. What it does give you is room to coexist, a way to take over the tables of a site that had a manager before, 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. - Taking over the manager of a site: point `tables` at the tables the site already has (`['groups' => 'groups', 'group_user' => 'group_user', 'pages' => 'pages']`). A migration of the package skips a table that exists and adds only a column it lacks, so rows stay where they are; `php artisan manager:doctor` lists columns that are still missing (`columns`). The names of the rights stay as they were when they follow `.` (`posts.write`, `pages.edit`, `leads.handle`) and, for a list of your own (`manager.resources`), `.view` and `.manage`: a group stored with only `services.manage` may also see the list, because the package adds what a right needs when it checks. - `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.` (`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. ```bash 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. - **A site with roles of its own** (decided in 0.5.0: groups stay the default, the site's roles are added next to them). `manager.permissions.mode` is `groups` (default), `host` (the groups are ignored) or `merge` (both). The site says what a role may do with `roles` (`['editor' => ['posts.view', 'posts.write'], 'owner' => ['*']]`, read from the attribute `role_attribute`: a string, a list or a relation with a `name`) or with a `resolver` class that implements `IriksIT\Manager\Contracts\PermissionResolver`. Values that are no permission of an active module are ignored and what a permission needs is added. A super admin may always do everything. The group screens still work in `host` mode but give nothing. - The migration adds `is_super_admin` to your users table (the table of `manager.user_model`). It promotes nobody. ## Checks on the login The login of the screens can ask for more. Write a class that extends `IriksIT\Manager\Support\Login\BaseLoginCheck` (the contract is `IriksIT\Manager\Contracts\LoginCheck`) and list it in `manager.login.checks`: - `fields()`: extra inputs on the form (`['name' => 'code', 'type' => 'text', 'label' => 'Code', 'autocomplete' => 'one-time-code']`); - `before($request)`: runs before the password is looked at: a captcha; - `after($request, $user)`: runs when the email and password are right and before anyone is logged in: a second factor. Refuse by throwing a `ValidationException`; the attempt then counts as a failed login, so the audit log and the bans see it. **Cloudflare Turnstile** is built in: set `MANAGER_TURNSTILE_SITE_KEY` and `MANAGER_TURNSTILE_SECRET` and the widget appears and is checked (a token that cannot be checked refuses the login). The widget loads a script from `challenges.cloudflare.com`; a strict Content-Security-Policy has to allow it. **There is no two-factor login in the package itself**: `after()` is the place for it, the code to make and keep the secrets is the site's. These checks belong to the login of the screens (`MANAGER_UI=package`); an app with its own login keeps its own. ## 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. - **Files at the IriksIT API** (the disk `iriksit`): set `MANAGER_MEDIA_DISK=iriksit` and `MANAGER_IRIKSIT_URL` (the address of the API with its version, for example `https://api.iriks-it.nl/v1`), `MANAGER_IRIKSIT_EMAIL` and `MANAGER_IRIKSIT_PASSWORD`. The account needs the permissions `storage.read` and `storage.write`. Run the migrations (table `storage_files`), then `php artisan manager:storage-check` writes, reads and deletes a test file and says what fails. The API keeps a file under an id of its own; the table remembers which path of the disk is which id, and a location without a slash that is not in the table is taken for an id (a row of a site's older code keeps working). Tokens are kept encrypted in the cache of the app. There are no folders and no listing on this disk. ## Commands | Command | What it does | |---|---| | `manager:install`, `manager:doctor [--json]` | Set the manager up, and check that it is wired in (for people and agents). | | `manager:create-user` | A super admin. | | `manager:users [--json]` | The accounts with their groups. | | `manager:user-password [--generate]` | A new password for an account (typed hidden, never an argument). | | `manager:settings list|get|set|reset|refresh` | The settings screen in the terminal; a secret is typed hidden or read from `--stdin`. | | `manager:import posts|pages|reviews|media` | Copy the rows of a site's own table (`--map`, `--set=disk=iriksit`, `--dry-run`). | | `manager:storage-check [--disk]` | Write, read and delete a test file on the disk of the media library. | | `manager:media-move ` | Move the library to another disk, keeping every address (`--dry-run`, `--verify`, `--delete-source`). | | `manager:media-prune` | List media nothing uses any more (`--older-than`), or files no row knows (`--orphans`); `--delete` removes. | | `manager:audit-prune`, `manager:unban`, `manager:make-theme` | Housekeeping of the audit log, bans and themes. | ## Field types `text`, `textarea`, `markdown`, `lines`, `media`, `url`, `number`, `date`, `toggle`, `select`, and for richer records: `slug` (`'from' => 'title'` fills it when empty), `list` (an array of short texts), `media_list` (a gallery), `repeater` (`'items' => ['question' => ['type' => 'text'], 'answer' => ['type' => 'textarea']]`, an array of items) and a `select` with `'source' => ['model' => Service::class, 'label' => 'title', 'value' => 'id']`. **Words for the simple face.** A field, a resource and a defined page can have words of their own for the simple face of the manager, for someone who is not a webmaster: `'phone' => ['label' => 'Phone number', 'help' => 'Shown on every page.', 'simple' => ['label' => 'Your phone number', 'help' => 'As you want people to read it.']]`; on a resource `'simple' => ['label' => 'What customers say', 'singular' => 'Customer review']` (also the menu item), on a page `'simple' => ['title' => 'About your business']`. A part left out falls back to the usual one, and the full face always shows the usual words. The presets (`Support\Presets`) bring plain-language words, which a site overrides like any other field. Used by pages and by `manager.resources`; a resource with a `model` writes straight into the site's own table (give JSON columns an `array` cast). ## Features of the site A site that lists parts of itself that its owner may want to switch off (services, projects, reviews, requests, a contact form) declares them once: ```php 'features' => ['services' => ['label' => 'Services', 'hint' => 'What you offer', 'enabled' => true, 'env' => 'SITE_SERVICES']], 'resources' => ['services' => ['feature' => 'services', 'label' => 'Services', 'fields' => [...]]], ``` Each feature is a toggle on the settings screen (group "Features of the site"). While it is off, the manager has no menu item, permission, screen or route for a resource with that `feature`, and the public site follows the same switch: `Features::on('services')`, `Route::get(...)->middleware('manager.feature:services')` (a 404 while off), `@feature('services') ... @endfeature` in Blade and `Features::flags()` to hand all of them to a page (links, sitemap, structured data). Off hides and never deletes: the data stays and comes back when the switch goes on. ## Screens for the owner (`numbers`, `costs`, the simple start screen) For someone who owns the business and does not build sites. They show up as big buttons on the simple start screen (`manager.simple_view`). - **`numbers`** (needs `statistics`): visitors, the contact buttons, requests (when `leads` is on and the account has `leads.view`), pages, how people found the site, in plain words, with three periods to choose from. Right `numbers.view`. - **`costs`**: the table of the site's `TOKENS.md` with the tokens of each piece of work in euros, per release, next to hours at an hourly rate, hosting and a discount (`manager.costs`). Right `costs.view`. A row is priced once and the price is kept in `work_costs`, by a pricer of the site (`manager.costs.pricer`, an invokable class), else by the IriksIT API with the account of `manager.media.iriksit` (needs `ai.pricing`), else by the fixed `manager.costs.rates`. `php artisan manager:costs-price` prices what is new, for example after a deploy. A site with no `TOKENS.md` shows an empty screen. - **The start screen** says more than a fixed line under a button: how many requests wait (and how many are new, as a badge on the button), how many posts wait, how many visitors came this week. `manager.simple.help` (`name`, `link`) adds a "Need help?" button, and `manager.simple.site_link` a "View the site" button. ## Requests module (`leads`) A request of a visitor (a callback request, a question, a quote, a contact form) is stored, screened and shown on the screen **Requests**. The forms are the site's own (their fields, words and thank-you page); a form validates what it got and then calls the package: ```php use IriksIT\Manager\Support\Leads\Intake; // in the form: , and a honeypot field the visitor never sees $lead = app(Intake::class)->take( ['kind' => 'question', 'name' => $name, 'phone' => $phone, 'email' => $email, 'message' => $message, 'about' => 'job', 'subject' => 'Roofing', 'page' => $path], Intake::secondsOpen($request->string('form_token')->toString()), // how long the form was open, null when the token says nothing (string) $request->ip(), (string) $request->userAgent(), ); // always show the normal thank-you, whatever folder it landed in ``` - **Screening** puts a request in the inbox, "other" (acquisition, or the visitor ticked "something else") or spam, with the reasons kept next to it. Nothing is refused; one signal alone is rarely enough. The rules and thresholds are `manager.leads` (`acquisition_words`, `throwaway_domains`, `spam_from`, `other_from`, `min_seconds`, `language`). - **Forms without code:** `POST /requests/{form}` (`manager.leads.form`) takes the request in: a form is a name with the kind it makes and the fields it requires (`name`, `phone`, `email`, `contact` for one box that takes either, `message`, `location`); `questions` and `moments` are what a visitor may tap. A honeypot field (`website`), the signed `form_token` (`Intake::formToken()`, or `GET /requests/token`), Turnstile (when its keys are set; send its token as `turnstile`) and a limit per address and for all addresses (`per_hour`, `per_hour_all`) keep programs out. JSON gets `201 {ok: true}`, a form in a page is redirected to `thanks` (or back). Name your own: `'terugbellen' => ['kind' => 'callback', 'require' => ['name', 'phone']]`. - **Told:** a real request is mailed to `manager.leads.notify` (a setting) with call, WhatsApp and mail buttons; the visitor is the Reply-To. A confirmation to the visitor is `manager.leads.confirm`. Replace the mail views by putting your own in `resources/views/vendor/manager/mail/`. - **Report and taps:** whoever has `leads.manage` sees what it brought in on the screen. A page counts a press on the number or the WhatsApp button with `POST /requests/tap` (`kind` call or whatsapp, `path`). A site with its own table moves it over with `php artisan manager:import leads --table=...` and `manager:import taps --table=...`. A contact form with a subject is the form `contact` (`kind` `message`; name, mail address, subject and message are required): `POST /requests/contact`. Contact messages a site stored in a table of its own come over with `manager:import leads --table=contact_messages --set=kind=message --map=opened_at=read_at`. - **Permissions:** `leads.view`, `leads.handle`, `leads.manage` (folders, reasons, blocking), `leads.delete`. - **Kept:** `php artisan manager:leads-prune` (schedule it daily) removes requests after `keep_days`, spam after `keep_spam_days` and expired blocks, and never a request with the outcome "won". - With a feature `leads` in `manager.features` the module follows that one switch instead of `manager.modules.leads`. ## Sharing module (`sharing`) Connects the owner's account of a social network (OAuth) and posts a published post there with the button **Share now** on the screen of the post. Off by default; it needs the posts module. - **LinkedIn** comes with the package. Create an app at LinkedIn with the products "Share on LinkedIn" and "Sign In with LinkedIn using OpenID Connect", put the address shown on the Sharing screen ("Return address for the app") in the app's redirect addresses, and fill in the client id and client secret on the settings screen (group "Sharing"; the secret is never shown again). Then press **Connect** under Sharing. - `manager.sharing.post_url` says where a post lives (`https://example.test/blog/{slug}`); the shared address gets `?via=linkedin`, so the statistics know where a reader came from. - **Dry run**: until the setting "Post for real" (`manager.sharing.live`) is on, a share is only written down (marked "dry run") and nothing is sent. Keep it off on a test site. - A site adds a network by writing a class that implements `IriksIT\Manager\Contracts\Sharer` and listing it: `'platforms' => ['linkedin' => LinkedInSharer::class, 'mastodon' => App\Sharing\MastodonSharer::class]`. - Tokens are stored encrypted and never leave the server; the connect step checks a session state and uses a PKCE verifier; what a platform says in an error is shown, a token never. - Not in the package: planning a share for later, X, Facebook and Instagram, and fetching recommendations from LinkedIn (see ADR-0010 in the repository). ## Pages of blocks A page can be built from blocks (hero, text with a picture, cards from a list, questions and answers, …): give a page definition `'blocks' => true` (or a list of block types) and read the blocks with `Blocks::for('home')`. Add your own types in `manager.blocks.types`. How they are drawn is your choice: - **Inertia + Vue:** pass `Blocks::for('home')` to the page and draw it with `BlockRenderer` from `resources/blocks/vue/` (import it with a Vite alias to `vendor/iriks-it/laravel-manager/resources/blocks`; pass your own components with `:components`). A component of your own must declare a `style` prop. - **Blade:** ``; change a view by putting the same file in `resources/views/blocks/` or publish them all with `php artisan vendor:publish --tag=manager-blocks`. - **Another frontend:** `MANAGER_BLOCKS_API=true` serves `GET /api/manager/pages/{slug}` and `GET /api/manager/blocks/schema` as JSON. **Live preview:** `MANAGER_BLOCKS_PREVIEW=true` shows the real public page next to the editor (phone, tablet, desktop), with the blocks that are not saved yet. The page address is `manager.blocks.preview.url` (`/{slug}` by default, the home page is `/`, or an invokable class). The preview address carries a signed, short-lived `?mb-preview=` token; only a person logged in with `pages.edit` sees the draft, and your site must not cache that response. Changing blocks needs the right `pages.layout`. A service or a project can have a page of its own: give its list `'template' => true`, and the list gets a "Page layout" button. In it, a text says `{record.title}` and the page fills it in; a `cards` block can show the projects of this service (`match_list` = `service_id`, `match_record` = `id`). Your route loads the record and passes `Blocks::forRecord('services', $service)` to the same renderer as a page; a frontend of its own reads `GET /api/manager/templates/services/{id}`. **Who draws the site:** `manager.frontend.mode` (`MANAGER_FRONTEND`, also on the settings screen as "Who shows the website"): `site` (default, the site draws its pages), `package` (the manager draws every page with blocks at `/{slug}`, the home page at `/`, as a fallback route that a route of the site always beats; the Blade view is `manager.frontend.layout`) or `headless` (the page API on, nothing drawn). A person in the simple face gets plainer words, a phone photo picker and no delete; see `docs/guide/building-pages.md`, which also says which photos a block needs. `php artisan vendor:publish --tag=manager-blocks-assets` copies a plain stylesheet (`blocks.css`, CSS variables) to `public/vendor/manager/`. A markdown field comes with its safe HTML as `_html`; print only that as HTML. **Style options and your own CSS (for example Tailwind).** A block type names style options (`background`, `width`, `spacing`, `columns`, …). The package only decides which *choices* exist, in `manager.blocks.tokens`: `'background' => ['none' => 'None', 'sand' => 'Sand', 'dark' => 'Dark']`. A block arrives with the chosen key (`style.background === 'sand'`), and your component or view turns it into the classes of your design system, so nothing of the design sits in the package: ```js const background = { none: '', sand: 'bg-sand-100', dark: 'bg-stone-900 text-white' } // in your component: :class="background[style.background]" ``` Write each class in full (Tailwind only finds classes that are spelled out in a file it scans), and a component of your own declares `style` in `defineProps`, or Vue puts it on the element as inline style. ## Settings module A screen (`/manager/settings`, only in the whole face of the manager) where an account with `settings.manage` switches parts of the manager on and off and changes settings, and an account with `settings.secrets` also changes keys, passwords and addresses (the IriksIT API, Turnstile, the disk of the media). - A change is kept in the table `settings` (secrets encrypted) and in one compiled file, `bootstrap/cache/manager-settings.php`, that is laid over the config while the app starts. So it works at once, on every server that shares the database, with or without `config:cache`, and a request reads one file from opcache, not the database. "Refresh now" writes that file again and empties the caches. Without the file the table is read. - `manager.settings.write_env` (`MANAGER_SETTINGS_WRITE_ENV`, off by default): also write the changed value into `.env`, when that file may be written. The old one is kept as `.env.manager-backup`. Only variables that a definition names are ever written. - Only what is defined can be set: the parts of the manager, the integrations of the package, and the site's own in `manager.settings.definitions` (`'site.contact_form' => ['label' => 'Contact form', 'type' => 'toggle', 'group' => 'Site']`; the key is the config path it overrides, so `config('site.contact_form')` has the answer). A module of your own can add some with a `settings()` method. - What can send a password or a file elsewhere (secrets, addresses, accounts, disks) needs `settings.secrets` and the password of whoever saves it. A secret is never sent to a browser; it is only said to be set. Clearing one is "back to what the config says". - A part that is switched on and misses its tables is named: run `php artisan migrate`. ## Pages module Pages are texts with keys, so the public site reads them and the owner edits them without code. Define a page in `config/manager.php`: ```php 'pages' => ['definitions' => ['home' => ['title' => 'Home', 'fields' => [ 'hero_title' => ['label' => 'Title on the photo', 'type' => 'text', 'default' => 'Welcome', 'max' => 120], 'intro' => ['label' => 'Story', 'type' => 'markdown'], 'photo' => ['label' => 'Photo', 'type' => 'media'], ]]]], ``` and read it with `IriksIT\Manager\Models\Page::contentFor('home')`: the stored values over the defaults, so a page that was never saved still has all its keys. Field types: `text`, `textarea`, `markdown`, `lines`, `media`, `url`, `number`, `date`, `toggle` and `select` (with `options`); `required`, `default`, `max`, `help` and `rules` work on all. The screens make the form, and the server validates and cleans every value by its type (a media or url value must be an address of the site or http(s)). A page without a definition is a free page with one Markdown text, a description for search engines and a publish switch; it can be made and removed in the screens. Permission: `pages.edit`. The definitions are shared code (`IriksIT\Manager\Support\Fields`), so other records can use them. ## 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. ## The editor Texts in Markdown (posts, free pages and `markdown` fields) have a toolbar (bold, italic, heading, list, quote, link), a **Photo** button that puts a picture from the media library into the text, and a **Preview** that is rendered by the server the way the site renders it (raw HTML is escaped; `POST /manager/markdown`, not written in the audit log). In the media library a click on a picture sets its **focus point** (`focus_x`, `focus_y`, 0 to 1): the part that must stay in view when the site crops it, shown in a square preview. There is no cropping or rotating in the manager: the file is kept as it was uploaded, and the site crops with the focus point. ## History module Every save of a post or a page keeps its state (`manager_revisions`, the newest 50 per record, `manager.revisions.keep`), with who saved it and which fields changed; saving the same state again keeps nothing. The post and page screens show the history, and `revisions.restore` puts an earlier state back, which is a save like any other (so what was there is in the history too). Whether a post is on the site (`published_at`) and whether a page is published is not part of the history: going back in time never publishes or hides anything. A live post can only be put back by someone who may publish. Permissions: `revisions.view` (and the permission to see that kind of text) and `revisions.restore` (and the permission to write it). A site adds its own models with `manager.revisions.types`, e.g. `'services' => ['model' => App\\Models\\Service::class, 'view' => 'services.view', 'restore' => 'services.manage']`. `MANAGER_REVISIONS=false` turns the module off. ## 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. - **The script**: put `` once in the layout of the public site (`:spa="true"` for a site with a client-side router). It loads `/pulse/pulse.js` (about 2 kB, plain JavaScript, no cookies or storage), reports the page and the time it was in view, and does nothing for a browser with Do Not Track or Global Privacy Control. With the module off the component prints nothing. Behind a Content-Security-Policy allow that one script address. - **Reporting** (what the script does, for a site that wants to do it itself): 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, roles of the host), media (library and public file route, focus point), posts (with categories and tags), pages with fields, lists defined in config, the history with restore, the audit log with bans, the statistics (with the counting script), the built-in screens for all of these (with a login, checks on the login, a profile and the simple view), an editor, themes, translations, a site's own bundle of screens, the import of existing data, and the install and doctor commands for AI agents. `composer test` runs the tests. Reviews are still a read-only list. 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`. Not in the package: two-factor login (the login checks are the place for it), cropping or rotating pictures, a theme editor. ## 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`: the job fails on any advisory). The check `PR CI / pr-ci` is green when all are. | | Push to production | verify (Pest, `composer audit`), tag and release, the tags to the mirror `laravel-manager-packagist`, Packagist, sync develop; then the homelab scans production with Trivy | | Every night | the homelab scans every repository with Trivy (03:00) and updates its dependencies (04:00): nothing runs weekly in this repository | | 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) | ### Security and updates Nothing here runs on a weekly schedule; the checks hang on the moments that matter, and the homelab does the rest every night. - **Every pull request:** `composer audit` (it fails on any advisory). - **Every release:** `composer audit` again on the merge to `production`. - **After every release to production:** Trivy scans `production` from the homelab (LXC 120, no database to download in a job). - **Every night:** Trivy scans every repository of the organisation (03:00), and the dependency round (04:00) opens a pull request `renovate/deps-DATE` straight to `production` for updates that have been public for 48 hours. PR CI tests it, and when it is merged the Release workflow makes a patch release of it (v0.5.0 → v0.5.1, text from the pull request), tells Packagist and syncs `develop`: one a night at most. While a release branch is open there is no patch release; the update goes out with that release. A critical advisory on the installed version skips the 48 hours. Packagist reads the mirror `iriks-it/laravel-manager-packagist`, not this repository, because it shows every branch of the repository it reads as a `dev-…` version. For every release the Release workflow (`.gitea/scripts/mirror_tags.sh`) puts a clean tree on the mirror: what `git archive` of the tag gives, so without what `.gitattributes` marks `export-ignore` (tests, `ui/`, `dev/`, `TOKENS.md`, `.gitea/`, the agent files), as a commit with no history and no branch, and pushes only its tag. The mirror has one branch, `production`, that only holds a note (no `composer.json`, so no version); nothing else is ever pushed there. Packagist and `composer require` only see the mirror, so this repository can be private. (Versions up to v0.5.1 on the mirror are the full tree.) 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`.