anthonyedmonds/govuk-laravel
Laravel package for building GOV.UK-style services and forms. It provides Blade components, form helpers and page templates that implement the GOV.UK Design System, so PHP applications can match government accessibility, styling and usability standards with minimal setup.
Start by installing the package with Composer and letting Laravel auto-discover its service provider:
composer require anthonyedmonds/govuk-laravel
Then publish the package’s config and frontend assets using the vendor:publish tags documented in the package README. At minimum, publish the config so you can inspect component namespaces, asset paths, and any layout defaults. If you plan to customise markup, also publish the views.
As of 8.7.0 the package also ships mail support (PR #156, “Feature/mail”). After upgrading, check the README for the mail-related publish tags and publish any mail views or mail theme files you intend to customise. This lets you send GOV.UK-styled transactional email from Laravel Mailables without hand-writing the markup, and keeps email templates alongside your web components.
The first practical use case is still a GOV.UK-styled form page: use the package layout for the header/footer, render an error summary, then build fields with the package’s Blade components. For example, a controller returns a view, and the Blade view composes GOV.UK form groups, inputs, radios, checkboxes, and a submit button. This gives you accessible GOV.UK markup without hand-writing the Design System HTML.
The second use case, new in 8.7.0, is a GOV.UK-styled confirmation or notification email. Build a Mailable, point it at the package’s mail views or mail components, pass the same data you would to a web view, and assert the rendered HTML in a test before sending.
Where to look first:
config/govuk.php after publishing.resources/views/vendor/govuk if you need to override web or mail markup.Compose pages from Blade components. Use the package’s layout and navigation components for consistent GOV.UK page structure, then compose forms and content from components such as error summary, input, textarea, select, radios, checkboxes, button, summary list, table, tabs, details, warning text, and panel. This keeps markup aligned with GOV.UK Frontend and reduces repeated accessibility markup.
Wire Laravel validation into GOV.UK components. Pass $errors into the view and render an error summary near the top of the page. Field components should receive the same name/id used by Laravel validation so error links work. Use old() for repopulating values after validation failures. A common workflow is:
old() and the error bag to set values and error classes.Send GOV.UK-styled mail. With 8.7.0, use the package’s mail views/components inside a Mailable rather than duplicating GOV.UK markup for email. A typical workflow is:
php artisan make:mail SubmissionConfirmation.build() or content(), return a package mail view or your own view that composes the package’s mail components.Mail::fake() plus a direct view render, so markup regressions are caught before deployment.config/mail.php, not in the package config.Keep mail content transactional and concise: a heading, a short body, a summary list for reference data, and a clear call to action. Reuse the same wording and summary-list structure as the corresponding web confirmation page so users see a consistent journey.
Use the Back to top component for long pages. The 8.6.0 release added a “Back to top” feature. Use it at the end of long guidance, tables, or multi-section pages. Ensure the target anchor exists and has a stable id, and keep the link text meaningful for screen readers. Place it after the main content rather than inside form controls. Note that this is a web-only affordance; don’t carry it into email templates.
Adopt the GOV.UK alignment changes deliberately. PR #153 (“Feature/govuk 65”) continued alignment with GOV.UK Frontend, and 8.7.0 builds on that baseline. After upgrading, compare key pages against the GOV.UK Design System examples. This is especially important for forms, error summaries, and components with updated classes or markup. Treat 8.7.0 as a minor release, but still smoke-test your most complex forms and at least one rendered email.
Integrate with your asset pipeline. If you customise GOV.UK Frontend assets, import the package’s CSS/JS according to its documentation, or publish and include the provided assets in your layout. If you use Vite or Mix, keep the GOV.UK asset entry points separate from application-specific styles so upgrades are easier. Email templates cannot rely on external stylesheets, so make sure any new mail views use inline or embedded styles rather than your application bundle.
Override views sparingly. Publish vendor views only for components you genuinely need to change — and, for mail, only the specific mail views you need to brand. Prefer wrapping package components in your own Blade components when you need project-specific defaults, such as consistently adding hints, prefixes, or suffixes.
php artisan view:clear.php artisan vendor:publish interactively to see the available tags rather than guessing, and re-run view:clear after publishing mail views.id matches the validation error key and that the error summary is rendered before the fields.php artisan config:cache as part of deployment. Do not edit files in vendor/.aria-* attributes, or IDs often explain accessibility or styling issues. For mail, compare against the GOV.UK notification/email guidance where available.resources/views/components directory and custom mail views in resources/views/vendor/govuk or your own mail view namespace.How can I help you explore Laravel packages today?