Repository navigation
Troubleshooting
Start with the two commands that find most problems:
php bin/raster lint # template mistakes, with file and line
php bin/raster doctor # setup problemsIn order of likelihood:
-
Spacing. It must be exactly
<!-- print.x.y -->: one space after<!--, one before-->.lintreports this andlint --fixrepairs it. -
The method returned
falseornull. That's the signal to keep the template's text. Check your model. -
It's inside a
removeblock, which is deleted before anything runs. -
A
print.keyinside a render block, but the row has no such key. The sample text stays for keys a row doesn't have. -
In production, a new CMS field shows its default until you run
php bin/raster schema --apply. -
A name with characters
drydoesn't accept. Indry.<view>.<fragment>, the view name may only contain lowercase letters,_and/, and the fragment name lowercase letters,_and-. No digits, and no-in view names.<!-- dry._part-2.box /-->is left in the page as a plain comment, andlintdoesn't catch it.
That's development mode stopping a broken page instead of showing half of it. The list gives each problem with file, line and column; the same list comes from lint. A common cause is a short closing tag: <!-- /render --> or a closing tag without the arguments doesn't close the block. The closing tag repeats the full opening name, <!-- /render.cms.news('limit=3') -->, and lint --fix writes it in for you. The response has status 500 and an X-Raster-Template-Errors header. Fix the errors, or temporarily render anyway with config::set('strict_templates')->to(false).
- The model must be at
application/models/<name>/<name>.phpand containclass <name>, all with the same lowercase name. - The method must be public.
-
lintsuggests the nearest real method name.php bin/raster vocabularylists every name a template can call.
The template calls a method with fewer (or more) arguments than its PHP signature has. Add them in the annotation, or give the PHP parameters default values.
Asset paths are relative to the theme folder: write href="style.css", not href="../style.css" or href="/style.css". Raster adds a <base> tag that makes this work on every URL. The tag is only added when your <head> tag is written exactly as <head>, without attributes. See Pages and URLs.
Because of that same <base> tag, #section points at the theme folder. Write href="about.html#section" or href="/about#section".
- The
<form>must havemethod="post"and be inside therender.<model>.<method>block that handles it.lintwarns about a post form outside any render block. - The handler must check
validation::get()->submitted(). It'sfalsefor other forms on the page, for GET requests, and for calls through/api. -
403 "this form was sent from another site": the browser reported a different origin. This happens when you open the site under one host name (
127.0.0.1:8000) and the form posts to another, or behind a proxy that changes the host. SetRASTER_URLto the address people use. - 403 "This form has expired": a logged-in user's session changed (they logged out and in elsewhere). Reload the page and send again.
- Put
validation.field('name')blocks inside the<form>. - The input needs a rule (
required,type,minlength…) forfieldto have anything to check.lintwarns when it doesn't. - For
alert('name')blocks: a model must callvalidation::get()->raise('name')orutil::done('name').lintwarns about alerts nobody raises.
-
In development they're not sent: look in
application/data/mail/. -
In production, check
RASTER_URLis set (emails with links aren't sent without it),RASTER_MAILpoints at a real SMTP server, andRASTER_MAIL_FROMis an address your provider may send from. -
mail::$last_errorholds the last failure. Listen to themail.failedevent to log them. - An SMTP server that doesn't offer encryption is refused; use
smtps://or, only if you must,?insecure=1.
That's the page cache (production only). Content saved through Raster clears it automatically. If your own model writes data, call util::content_changed() afterwards. After editing views, models or the database by hand, run php bin/raster cache clear. For pages that must always be fresh, add them to page_cache_skip. Check the X-Raster-Cache response header.
- It might be a draft (
enabled= 0) or scheduled (published_atin the future). Editors see these; visitors don't. Log out, or use a private window, to see what visitors see. - The list might be filtered (
featured=1) or limited (limit=3).
You're in production, where the structure only changes when you apply it:
RASTER_ENV=production php bin/raster schema --applyThe content is still there, in the old column. php bin/raster schema shows it as an orphan and suggests a --rename command that moves it to the new name. Run it (in production, before --apply).
- Files and folders starting with
_are never pages. - An item URL (
/news/news_item/x) is 404 when there's no such item (or it's a draft and you're not logged in), and only works under its own collection name. - A route in
the_routes.phpmight be catching the URL first. Routes win over files.
It found edited framework files, listed in its output. Move your changes into your app (see Extending Raster), then run it again. --force updates anyway and keeps the old files in application/data/backups/.
Add log::enable(); to config/the_app.php. Every event and SQL query is then printed to the browser's JavaScript console. Remove it when you're done, or switch it on only in development as shown in Events.
A config file in application/config/ is missing its opening <?php, so PHP prints it instead of running it. The starter's the_events.php is empty; add <?php as its first line before writing bindings.
Raster PHP · Repository · AGENTS.md (full specification) · Changelog · Demo café
Start here
Building pages
Content
Visitors
Running a site
- Settings and environments
- Command line
- Deploying to production
- Static export
- Updating Raster
- Security
More