first commit
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
## Laravel Boost
|
||||
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
|
||||
|
||||
## Artisan
|
||||
- Use the `list-artisan-commands` tool when you need to call an Artisan command to double-check the available parameters.
|
||||
|
||||
## URLs
|
||||
- Whenever you share a project URL with the user, you should use the `get-absolute-url` tool to ensure you're using the correct scheme, domain/IP, and port.
|
||||
|
||||
## Tinker / Debugging
|
||||
- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly.
|
||||
- Use the `database-query` tool when you only need to read from the database.
|
||||
|
||||
@if (config('boost.browser_logs', true) !== false || config('boost.browser_logs_watcher', true) !== false)
|
||||
## Reading Browser Logs With the `browser-logs` Tool
|
||||
- You can read browser logs, errors, and exceptions using the `browser-logs` tool from Boost.
|
||||
- Only recent browser logs will be useful - ignore old logs.
|
||||
@endif
|
||||
|
||||
## Searching Documentation (Critically Important)
|
||||
- Boost comes with a powerful `search-docs` tool you should use before any other approaches when dealing with Laravel or Laravel ecosystem packages. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages.
|
||||
- The `search-docs` tool is perfect for all Laravel-related packages, including Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, Nightwatch, etc.
|
||||
- You must use this tool to search for Laravel ecosystem documentation before falling back to other approaches.
|
||||
- Search the documentation before making code changes to ensure we are taking the correct approach.
|
||||
- Use multiple, broad, simple, topic-based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`.
|
||||
- Do not add package names to queries; package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`.
|
||||
|
||||
### Available Search Syntax
|
||||
- You can and should pass multiple queries at once. The most relevant results will be returned first.
|
||||
|
||||
1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'.
|
||||
2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit".
|
||||
3. Quoted Phrases (Exact Position) - query="infinite scroll" - words must be adjacent and in that order.
|
||||
4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit".
|
||||
5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms.
|
||||
@@ -0,0 +1,7 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Test Enforcement
|
||||
|
||||
- Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass.
|
||||
- Run the minimum number of tests needed to ensure code quality and speed. Use `{{ $assist->artisanCommand('test --compact') }}` with a specific filename or filter.
|
||||
@@ -0,0 +1,20 @@
|
||||
## Flux UI Free
|
||||
|
||||
- This project is using the free edition of Flux UI. It has full access to the free components and variants, but does not have access to the Pro components.
|
||||
- Flux UI is a component library for Livewire. Flux is a robust, hand-crafted UI component library for your Livewire applications. It's built using Tailwind CSS and provides a set of components that are easy to use and customize.
|
||||
- You should use Flux UI components when available.
|
||||
- Fallback to standard Blade components if Flux is unavailable.
|
||||
- If available, use the `search-docs` tool to get the exact documentation and code snippets available for this project.
|
||||
- Flux UI components look like this:
|
||||
@verbatim
|
||||
<code-snippet name="Flux UI Component Example" lang="blade">
|
||||
<flux:button variant="primary"/>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
|
||||
### Available Components
|
||||
This is correct as of Boost installation, but there may be additional components within the codebase.
|
||||
|
||||
<available-flux-components>
|
||||
avatar, badge, brand, breadcrumbs, button, callout, checkbox, dropdown, field, heading, icon, input, modal, navbar, otp-input, profile, radio, select, separator, skeleton, switch, text, textarea, tooltip
|
||||
</available-flux-components>
|
||||
@@ -0,0 +1,20 @@
|
||||
## Flux UI Pro
|
||||
|
||||
- This project is using the Pro version of Flux UI. It has full access to the free components and variants, as well as full access to the Pro components and variants.
|
||||
- Flux UI is a component library for Livewire. Flux is a robust, hand-crafted UI component library for your Livewire applications. It's built using Tailwind CSS and provides a set of components that are easy to use and customize.
|
||||
- You should use Flux UI components when available.
|
||||
- Fallback to standard Blade components if Flux is unavailable.
|
||||
- If available, use the `search-docs` tool to get the exact documentation and code snippets available for this project.
|
||||
- Flux UI components look like this:
|
||||
@verbatim
|
||||
<code-snippet name="Flux UI Component Example" lang="blade">
|
||||
<flux:button variant="primary"/>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
|
||||
### Available Components
|
||||
This is correct as of Boost installation, but there may be additional components within the codebase.
|
||||
|
||||
<available-flux-components>
|
||||
accordion, autocomplete, avatar, badge, brand, breadcrumbs, button, calendar, callout, card, chart, checkbox, command, composer, context, date-picker, dropdown, editor, field, file-upload, heading, icon, input, kanban, modal, navbar, otp-input, pagination, pillbox, popover, profile, radio, select, separator, skeleton, slider, switch, table, tabs, text, textarea, time-picker, toast, tooltip
|
||||
</available-flux-components>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Laravel Folio
|
||||
|
||||
- Laravel Folio is a file-based router. With Laravel Folio, a new route is created for every Blade file within the configured Folio directory. For example, pages are usually in `resources/views/pages/` and the file structure determines routes:
|
||||
- `pages/index.blade.php` → `/`
|
||||
- `pages/profile/index.blade.php` → `/profile`
|
||||
- `pages/auth/login.blade.php` → `/auth/login`
|
||||
- You may list available Folio routes using `{{ $assist->artisanCommand('folio:list') }}` or using the `list-routes` tool.
|
||||
|
||||
### New Pages & Routes
|
||||
- Always create new `folio` pages and routes using `{{ $assist->artisanCommand('folio:page [name]') }}` following existing naming conventions.
|
||||
|
||||
<code-snippet name="Example folio:page Commands for Automatic Routing" lang="shell">
|
||||
// Creates: resources/views/pages/products.blade.php → /products
|
||||
{!! $assist->artisanCommand('folio:page "products"') !!}
|
||||
|
||||
// Creates: resources/views/pages/products/[id].blade.php → /products/{id}
|
||||
{!! $assist->artisanCommand('folio:page "products/[id]"') !!}
|
||||
</code-snippet>
|
||||
|
||||
- Add a 'name' to each new Folio page at the very top of the file so it has a named route available for other parts of the codebase to use.
|
||||
@verbatim
|
||||
<code-snippet name="Adding Named Route to Folio Page" lang="php">
|
||||
use function Laravel\Folio\name;
|
||||
|
||||
name('products.index');
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
|
||||
### Support & Documentation
|
||||
- Folio supports: middleware, serving pages from multiple paths, subdomain routing, named routes, nested routes, index routes, route parameters, and route model binding.
|
||||
- If available, use the `search-docs` tool to use Folio to its full potential and help the user effectively.
|
||||
@verbatim
|
||||
<code-snippet name="Folio Middleware Example" lang="php">
|
||||
use function Laravel\Folio\{name, middleware};
|
||||
|
||||
name('admin.products');
|
||||
middleware(['auth', 'verified', 'can:manage-products']);
|
||||
?>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
# Laravel Boost Guidelines
|
||||
|
||||
The Laravel Boost guidelines are specifically curated by Laravel maintainers for this application. These guidelines should be followed closely to enhance the user's satisfaction building Laravel applications.
|
||||
|
||||
## Foundational Context
|
||||
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
|
||||
|
||||
- php - {{ PHP_VERSION }}
|
||||
@foreach (app(\Laravel\Roster\Roster::class)->packages()->unique(fn ($package) => $package->rawName()) as $package)
|
||||
- {{ $package->rawName() }} ({{ $package->name() }}) - v{{ $package->majorVersion() }}
|
||||
@endforeach
|
||||
|
||||
@if (! empty(config('boost.purpose')))
|
||||
Application purpose: {!! config('boost.purpose') !!}
|
||||
|
||||
@endif
|
||||
## Conventions
|
||||
- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, and naming.
|
||||
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
|
||||
- Check for existing components to reuse before writing a new one.
|
||||
|
||||
## Verification Scripts
|
||||
- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important.
|
||||
|
||||
## Application Structure & Architecture
|
||||
- Stick to existing directory structure; don't create new base folders without approval.
|
||||
- Do not change the application's dependencies without approval.
|
||||
|
||||
## Frontend Bundling
|
||||
- If the user doesn't see a frontend change reflected in the UI, it could mean they need to run `{{ $assist->nodePackageManagerCommand('run build') }}`, `{{ $assist->nodePackageManagerCommand('run dev') }}`, or `{{ $assist->composerCommand('run dev') }}`. Ask them.
|
||||
|
||||
## Replies
|
||||
- Be concise in your explanations - focus on what's important rather than explaining obvious details.
|
||||
|
||||
## Documentation Files
|
||||
- You must only create documentation files if explicitly requested by the user.
|
||||
@@ -0,0 +1,4 @@
|
||||
## Laravel Herd
|
||||
|
||||
- The application is served by Laravel Herd and will be available at: `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate URLs for the user to ensure valid URLs.
|
||||
- You must not run any commands to make the site available via HTTP(S). It is always available through Laravel Herd.
|
||||
@@ -0,0 +1,8 @@
|
||||
## Inertia v1
|
||||
|
||||
- Inertia v1 does not come with these features. Do not recommend using these Inertia v2 features directly:
|
||||
- Deferred props.
|
||||
- Infinite scrolling using merging props and `WhenVisible`.
|
||||
- Lazy loading data on scroll.
|
||||
- Polling.
|
||||
- Prefetching.
|
||||
@@ -0,0 +1,26 @@
|
||||
## Inertia v2
|
||||
|
||||
- Make use of all Inertia features from v1 and v2. Check the documentation before making any changes to ensure we are taking the correct approach.
|
||||
|
||||
### Inertia v2 New Features
|
||||
- Deferred props.
|
||||
- Infinite scrolling using merging props and `WhenVisible`.
|
||||
- Lazy loading data on scroll.
|
||||
- Polling.
|
||||
- Prefetching.
|
||||
|
||||
### Deferred Props & Empty States
|
||||
- When using deferred props on the frontend, you should add a nice empty state with pulsing/animated skeleton.
|
||||
|
||||
### Inertia Form General Guidance
|
||||
@if ($assist->inertia()->hasFormComponent())
|
||||
- The recommended way to build forms when using Inertia is with the `<Form>` component - a useful example is below. Use the `search-docs` tool with a query of `form component` for guidance.
|
||||
- Forms can also be built using the `useForm` helper for more programmatic control, or to follow existing conventions. Use the `search-docs` tool with a query of `useForm helper` for guidance.
|
||||
@if ($assist->inertia()->hasFormComponentResets())
|
||||
- `resetOnError`, `resetOnSuccess`, and `setDefaultsOnSuccess` are available on the `<Form>` component. Use the `search-docs` tool with a query of `form component resetting` for guidance.
|
||||
@else
|
||||
- This version of Inertia does not support `resetOnError`, `resetOnSuccess`, or `setDefaultsOnSuccess` on the `<Form>` component. Using these will cause errors.
|
||||
@endif
|
||||
@else
|
||||
- Build forms using the `useForm` helper. Use the code examples and the `search-docs` tool with a query of `useForm helper` for guidance.
|
||||
@endif
|
||||
@@ -0,0 +1,14 @@
|
||||
## Inertia
|
||||
|
||||
- Inertia.js components should be placed in the `{{ $assist->inertia()->pagesDirectory() }}` directory unless specified differently in the JS bundler (`vite.config.js`).
|
||||
- Use `Inertia::render()` for server-side routing instead of traditional Blade views.
|
||||
- Use the `search-docs` tool for accurate guidance on all things Inertia.
|
||||
|
||||
<code-snippet name="Inertia Render Example" lang="php">
|
||||
// routes/web.php example
|
||||
Route::get('/users', function () {
|
||||
return Inertia::render('Users/Index', [
|
||||
'users' => User::all()
|
||||
]);
|
||||
});
|
||||
</code-snippet>
|
||||
@@ -0,0 +1,45 @@
|
||||
## Inertia v1 + React Forms
|
||||
|
||||
- For form handling in Inertia pages, use `router.post` and related methods. Do not use regular forms.
|
||||
@verbatim
|
||||
<code-snippet name="Inertia React Form Example" lang="react">
|
||||
import { useState } from 'react'
|
||||
import { router } from '@inertiajs/react'
|
||||
|
||||
export default function Edit() {
|
||||
const [values, setValues] = useState({
|
||||
first_name: "",
|
||||
last_name: "",
|
||||
email: "",
|
||||
})
|
||||
|
||||
function handleChange(e) {
|
||||
const key = e.target.id;
|
||||
const value = e.target.value
|
||||
|
||||
setValues(values => ({
|
||||
...values,
|
||||
[key]: value,
|
||||
}))
|
||||
}
|
||||
|
||||
function handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
|
||||
router.post('/users', values)
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<label htmlFor="first_name">First name:</label>
|
||||
<input id="first_name" value={values.first_name} onChange={handleChange} />
|
||||
<label htmlFor="last_name">Last name:</label>
|
||||
<input id="last_name" value={values.last_name} onChange={handleChange} />
|
||||
<label htmlFor="email">Email:</label>
|
||||
<input id="email" value={values.email} onChange={handleChange} />
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@@ -0,0 +1,66 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Inertia v2 + React Forms
|
||||
|
||||
@if($assist->inertia()->hasFormComponent())
|
||||
@boostsnippet("`<Form>` Component Example", "react")
|
||||
import { Form } from '@inertiajs/react'
|
||||
|
||||
export default () => (
|
||||
<Form action="/users" method="post">
|
||||
{({
|
||||
errors,
|
||||
hasErrors,
|
||||
processing,
|
||||
wasSuccessful,
|
||||
recentlySuccessful,
|
||||
clearErrors,
|
||||
resetAndClearErrors,
|
||||
defaults
|
||||
}) => (
|
||||
<>
|
||||
<input type="text" name="name" />
|
||||
|
||||
{errors.name && <div>{errors.name}</div>}
|
||||
|
||||
<button type="submit" disabled={processing}>
|
||||
{processing ? 'Creating...' : 'Create User'}
|
||||
</button>
|
||||
|
||||
{wasSuccessful && <div>User created successfully!</div>}
|
||||
</>
|
||||
)}
|
||||
</Form>
|
||||
)
|
||||
@endboostsnippet
|
||||
@endif
|
||||
|
||||
@if($assist->inertia()->hasFormComponent() === false)
|
||||
{{-- Inertia 2.0.x, not 2.1.0 or higher. So still need to use 'useForm' --}}
|
||||
@boostsnippet("Inertia React useForm Example", "react")
|
||||
import { useForm } from '@inertiajs/react'
|
||||
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
email: '',
|
||||
password: '',
|
||||
remember: false,
|
||||
})
|
||||
|
||||
function submit(e) {
|
||||
e.preventDefault()
|
||||
post('/login')
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={submit}>
|
||||
<input type="text" value={data.email} onChange={e => setData('email', e.target.value)} />
|
||||
{errors.email && <div>{errors.email}</div>}
|
||||
<input type="password" value={data.password} onChange={e => setData('password', e.target.value)} />
|
||||
{errors.password && <div>{errors.password}</div>}
|
||||
<input type="checkbox" checked={data.remember} onChange={e => setData('remember', e.target.checked)} /> Remember Me
|
||||
<button type="submit" disabled={processing}>Login</button>
|
||||
</form>
|
||||
)
|
||||
@endboostsnippet
|
||||
@endif
|
||||
@@ -0,0 +1,8 @@
|
||||
## Inertia + React
|
||||
|
||||
- Use `router.visit()` or `<Link>` for navigation instead of traditional links.
|
||||
|
||||
@boostsnippet("Inertia Client Navigation", "react")
|
||||
import { Link } from '@inertiajs/react'
|
||||
<Link href="/">Home</Link>
|
||||
@endboostsnippet
|
||||
@@ -0,0 +1,33 @@
|
||||
## Inertia v1 + Svelte Forms
|
||||
|
||||
- For form handling, use `router.post` and related methods. Do not use regular forms.
|
||||
@verbatim
|
||||
<code-snippet name="Inertia Svelte Form Example" lang="svelte">
|
||||
<script>
|
||||
import { router } from '@inertiajs/svelte'
|
||||
|
||||
let values = {
|
||||
first_name: null,
|
||||
last_name: null,
|
||||
email: null,
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
router.post('/users', values)
|
||||
}
|
||||
</script>
|
||||
|
||||
<form on:submit|preventDefault={handleSubmit}>
|
||||
<label for="first_name">First name:</label>
|
||||
<input id="first_name" bind:value={values.first_name}>
|
||||
|
||||
<label for="last_name">Last name:</label>
|
||||
<input id="last_name" bind:value={values.last_name}>
|
||||
|
||||
<label for="email">Email:</label>
|
||||
<input id="email" bind:value={values.email}>
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@@ -0,0 +1,75 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Inertia v2 + Svelte Forms
|
||||
|
||||
- There are critical differences between Svelte 4 and 5; use the `search-docs` tool for up-to-date guidance.
|
||||
|
||||
@if($assist->inertia()->hasFormComponent())
|
||||
@boostsnippet("`<Form>` Component Example", "svelte5")
|
||||
<Form action="/users" method="post">
|
||||
{#snippet children({
|
||||
errors,
|
||||
hasErrors,
|
||||
processing,
|
||||
progress,
|
||||
wasSuccessful,
|
||||
recentlySuccessful,
|
||||
setError,
|
||||
clearErrors,
|
||||
resetAndClearErrors,
|
||||
defaults,
|
||||
isDirty,
|
||||
reset,
|
||||
submit,
|
||||
})}
|
||||
<input type="text" name="name" />
|
||||
|
||||
{#if errors.name}
|
||||
<div>{errors.name}</div>
|
||||
{/if}
|
||||
|
||||
<button type="submit" disabled={processing}>
|
||||
{processing ? 'Creating...' : 'Create User'}
|
||||
</button>
|
||||
|
||||
{#if wasSuccessful}
|
||||
<div>User created successfully!</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</Form>
|
||||
@endboostsnippet
|
||||
@endif
|
||||
|
||||
@if($assist->inertia()->hasFormComponent() === false)
|
||||
{{-- Inertia 2.0.x, not 2.1.0 or higher. So they still need to use 'useForm' --}}
|
||||
@boostsnippet("Inertia Svelte useForm Example", "svelte")
|
||||
<script>
|
||||
import { useForm } from '@inertiajs/svelte'
|
||||
|
||||
const form = useForm({
|
||||
email: null,
|
||||
password: null,
|
||||
remember: false,
|
||||
})
|
||||
|
||||
function submit(e) {
|
||||
e.preventDefault() /* Only required with Svelte 5 */
|
||||
$form.post('/login')
|
||||
}
|
||||
</script>
|
||||
|
||||
<form onsubmit={submit}>
|
||||
<input type="text" bind:value={$form.email} />
|
||||
{#if $form.errors.email}
|
||||
<div class="form-error">{$form.errors.email}</div>
|
||||
{/if}
|
||||
<input type="password" bind:value={$form.password} />
|
||||
{#if $form.errors.password}
|
||||
<div class="form-error">{$form.errors.password}</div>
|
||||
{/if}
|
||||
<input type="checkbox" bind:checked={$form.remember} /> Remember Me
|
||||
<button type="submit" disabled={$form.processing}>Submit</button>
|
||||
</form>
|
||||
@endboostsnippet
|
||||
@endif
|
||||
@@ -0,0 +1,10 @@
|
||||
## Inertia + Svelte
|
||||
|
||||
- Use `router.visit()` or `<Link>` for navigation instead of traditional links.
|
||||
|
||||
@boostsnippet("Inertia Client Navigation", "svelte")
|
||||
import { inertia, Link } from '@inertiajs/svelte'
|
||||
|
||||
<a href="/" use:inertia>Home</a>
|
||||
<Link href="/">Home</Link>
|
||||
@endboostsnippet
|
||||
@@ -0,0 +1,37 @@
|
||||
## Inertia v1 + Vue Forms
|
||||
|
||||
- For form handling in Inertia pages, use `router.post` and related methods. Do not use regular forms.
|
||||
@verbatim
|
||||
<code-snippet name="Inertia Vue Form Example" lang="vue">
|
||||
<script setup>
|
||||
import { reactive } from 'vue'
|
||||
import { router } from '@inertiajs/vue3'
|
||||
import { usePage } from '@inertiajs/vue3'
|
||||
|
||||
const page = usePage()
|
||||
|
||||
const form = reactive({
|
||||
first_name: null,
|
||||
last_name: null,
|
||||
email: null,
|
||||
})
|
||||
|
||||
function submit() {
|
||||
router.post('/users', form)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>Create {{ page.modelName }}</h1>
|
||||
<form @submit.prevent="submit">
|
||||
<label for="first_name">First name:</label>
|
||||
<input id="first_name" v-model="form.first_name" />
|
||||
<label for="last_name">Last name:</label>
|
||||
<input id="last_name" v-model="form.last_name" />
|
||||
<label for="email">Email:</label>
|
||||
<input id="email" v-model="form.email" />
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</template>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@@ -0,0 +1,70 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Inertia v2 + Vue Forms
|
||||
|
||||
@if($assist->inertia()->hasFormComponent())
|
||||
@boostsnippet("`<Form>` Component Example", "vue")
|
||||
<Form
|
||||
action="/users"
|
||||
method="post"
|
||||
#default="{
|
||||
errors,
|
||||
hasErrors,
|
||||
processing,
|
||||
progress,
|
||||
wasSuccessful,
|
||||
recentlySuccessful,
|
||||
setError,
|
||||
clearErrors,
|
||||
resetAndClearErrors,
|
||||
defaults,
|
||||
isDirty,
|
||||
reset,
|
||||
submit,
|
||||
}"
|
||||
>
|
||||
<input type="text" name="name" />
|
||||
|
||||
<div v-if="errors.name">
|
||||
{{ errors.name }}
|
||||
</div>
|
||||
|
||||
<button type="submit" :disabled="processing">
|
||||
{{ processing ? 'Creating...' : 'Create User' }}
|
||||
</button>
|
||||
|
||||
<div v-if="wasSuccessful">User created successfully!</div>
|
||||
</Form>
|
||||
@endboostsnippet
|
||||
@endif
|
||||
|
||||
@if($assist->inertia()->hasFormComponent() === false)
|
||||
{{-- Inertia 2.0.x, not 2.1.0 or higher. So still need to use 'useForm' --}}
|
||||
@boostsnippet("Inertia Vue useForm example", "vue")
|
||||
<script setup>
|
||||
import { useForm } from '@inertiajs/vue3'
|
||||
|
||||
const form = useForm({
|
||||
email: null,
|
||||
password: null,
|
||||
remember: false,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<form @submit.prevent="form.post('/login')">
|
||||
<!-- email -->
|
||||
<input type="text" v-model="form.email">
|
||||
<div v-if="form.errors.email">{{ form.errors.email }}</div>
|
||||
<!-- password -->
|
||||
<input type="password" v-model="form.password">
|
||||
<div v-if="form.errors.password">{{ form.errors.password }}</div>
|
||||
<!-- remember me -->
|
||||
<input type="checkbox" v-model="form.remember"> Remember Me
|
||||
<!-- submit -->
|
||||
<button type="submit" :disabled="form.processing">Login</button>
|
||||
</form>
|
||||
</template>
|
||||
@endboostsnippet
|
||||
@endif
|
||||
@@ -0,0 +1,9 @@
|
||||
## Inertia + Vue
|
||||
|
||||
- Vue components must have a single root element.
|
||||
- Use `router.visit()` or `<Link>` for navigation instead of traditional links.
|
||||
|
||||
@boostsnippet("Inertia Client Navigation", "vue")
|
||||
import { Link } from '@inertiajs/vue3'
|
||||
<Link href="/">Home</Link>
|
||||
@endboostsnippet
|
||||
@@ -0,0 +1,10 @@
|
||||
## Laravel 10
|
||||
|
||||
- Use the `search-docs` tool to get version-specific documentation.
|
||||
- Middleware typically live in `app/Http/Middleware/` and service providers in `app/Providers/`.
|
||||
- Laravel 10 has a `bootstrap/app.php` file that creates the application instance and binds kernel contracts, but does not use it for application configuration like Laravel 11:
|
||||
- Middleware registration is in `app/Http/Kernel.php`
|
||||
- Exception handling is in `app/Exceptions/Handler.php`
|
||||
- Console commands and schedule registration is in `app/Console/Kernel.php`
|
||||
- Rate limits likely exist in `RouteServiceProvider` or `app/Http/Kernel.php`
|
||||
- When using Eloquent model casts, you must use `protected $casts = [];` and not the `casts()` method. The `casts()` method isn't available on models in Laravel 10.
|
||||
@@ -0,0 +1,41 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Laravel 11
|
||||
|
||||
- Use the `search-docs` tool to get version-specific documentation.
|
||||
@if (file_exists(base_path('app/Http/Kernel.php')))
|
||||
- This project upgraded from Laravel 10 without migrating to the new streamlined Laravel 11 file structure.
|
||||
- This is **perfectly fine** and recommended by Laravel. Follow the existing structure from Laravel 10. We do not need to migrate to the Laravel 11 structure unless the user explicitly requests it.
|
||||
|
||||
### Laravel 10 Structure
|
||||
- Middleware typically lives in `app/Http/Middleware/` and service providers in `app/Providers/`.
|
||||
- There is no `bootstrap/app.php` application configuration in a Laravel 10 structure:
|
||||
- Middleware registration is in `app/Http/Kernel.php`
|
||||
- Exception handling is in `app/Exceptions/Handler.php`
|
||||
- Console commands and schedule registration is in `app/Console/Kernel.php`
|
||||
- Rate limits likely exist in `RouteServiceProvider` or `app/Http/Kernel.php`
|
||||
@else
|
||||
- Laravel 11 brought a new streamlined file structure which this project now uses.
|
||||
|
||||
### Laravel 11 Structure
|
||||
- In Laravel 11, middleware are no longer registered in `app/Http/Kernel.php`.
|
||||
- Middleware are configured declaratively in `bootstrap/app.php` using `Application::configure()->withMiddleware()`.
|
||||
- `bootstrap/app.php` is the file to register middleware, exceptions, and routing files.
|
||||
- `bootstrap/providers.php` contains application specific service providers.
|
||||
- **No app\Console\Kernel.php** - use `bootstrap/app.php` or `routes/console.php` for console configuration.
|
||||
- **Commands auto-register** - files in `app/Console/Commands/` are automatically available and do not require manual registration.
|
||||
@endif
|
||||
|
||||
### Database
|
||||
- When modifying a column, the migration must include all of the attributes that were previously defined on the column. Otherwise, they will be dropped and lost.
|
||||
- Laravel 11 allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`.
|
||||
|
||||
### Models
|
||||
- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models.
|
||||
|
||||
### New Artisan Commands
|
||||
- List Artisan commands using Boost's MCP tool, if available. New commands available in Laravel 11:
|
||||
- `{{ $assist->artisanCommand('make:enum') }}`
|
||||
- `{{ $assist->artisanCommand('make:class') }}`
|
||||
- `{{ $assist->artisanCommand('make:interface') }}`
|
||||
@@ -0,0 +1,32 @@
|
||||
## Laravel 12
|
||||
|
||||
- Use the `search-docs` tool to get version-specific documentation.
|
||||
@if (file_exists(base_path('app/Http/Kernel.php')))
|
||||
- This project upgraded from Laravel 10 without migrating to the new streamlined Laravel file structure.
|
||||
- This is **perfectly fine** and recommended by Laravel. Follow the existing structure from Laravel 10. We do not need to migrate to the new Laravel structure unless the user explicitly requests it.
|
||||
|
||||
### Laravel 10 Structure
|
||||
- Middleware typically lives in `app/Http/Middleware/` and service providers in `app/Providers/`.
|
||||
- There is no `bootstrap/app.php` application configuration in a Laravel 10 structure:
|
||||
- Middleware registration happens in `app/Http/Kernel.php`
|
||||
- Exception handling is in `app/Exceptions/Handler.php`
|
||||
- Console commands and schedule register in `app/Console/Kernel.php`
|
||||
- Rate limits likely exist in `RouteServiceProvider` or `app/Http/Kernel.php`
|
||||
@else
|
||||
- Since Laravel 11, Laravel has a new streamlined file structure which this project uses.
|
||||
|
||||
### Laravel 12 Structure
|
||||
- In Laravel 12, middleware are no longer registered in `app/Http/Kernel.php`.
|
||||
- Middleware are configured declaratively in `bootstrap/app.php` using `Application::configure()->withMiddleware()`.
|
||||
- `bootstrap/app.php` is the file to register middleware, exceptions, and routing files.
|
||||
- `bootstrap/providers.php` contains application specific service providers.
|
||||
- The `app\Console\Kernel.php` file no longer exists; use `bootstrap/app.php` or `routes/console.php` for console configuration.
|
||||
- Console commands in `app/Console/Commands/` are automatically available and do not require manual registration.
|
||||
@endif
|
||||
|
||||
### Database
|
||||
- When modifying a column, the migration must include all of the attributes that were previously defined on the column. Otherwise, they will be dropped and lost.
|
||||
- Laravel 12 allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`.
|
||||
|
||||
### Models
|
||||
- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models.
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Do Things the Laravel Way
|
||||
|
||||
- Use `{{ $assist->artisanCommand('make:') }}` commands to create new files (i.e. migrations, controllers, models, etc.). You can list available Artisan commands using the `list-artisan-commands` tool.
|
||||
- If you're creating a generic PHP class, use `{{ $assist->artisanCommand('make:class') }}`.
|
||||
- Pass `--no-interaction` to all Artisan commands to ensure they work without user input. You should also pass the correct `--options` to ensure correct behavior.
|
||||
|
||||
### Database
|
||||
- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins.
|
||||
- Use Eloquent models and relationships before suggesting raw database queries.
|
||||
- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them.
|
||||
- Generate code that prevents N+1 query problems by using eager loading.
|
||||
- Use Laravel's query builder for very complex database operations.
|
||||
|
||||
### Model Creation
|
||||
- When creating new models, create useful factories and seeders for them too. Ask the user if they need any other things, using `list-artisan-commands` to check the available options to `{{ $assist->artisanCommand('make:model') }}`.
|
||||
|
||||
### APIs & Eloquent Resources
|
||||
- For APIs, default to using Eloquent API Resources and API versioning unless existing API routes do not, then you should follow existing application convention.
|
||||
|
||||
### Controllers & Validation
|
||||
- Always create Form Request classes for validation rather than inline validation in controllers. Include both validation rules and custom error messages.
|
||||
- Check sibling Form Requests to see if the application uses array or string based validation rules.
|
||||
|
||||
### Queues
|
||||
- Use queued jobs for time-consuming operations with the `ShouldQueue` interface.
|
||||
|
||||
### Authentication & Authorization
|
||||
- Use Laravel's built-in authentication and authorization features (gates, policies, Sanctum, etc.).
|
||||
|
||||
### URL Generation
|
||||
- When generating links to other pages, prefer named routes and the `route()` function.
|
||||
|
||||
### Configuration
|
||||
- Use environment variables only in configuration files - never use the `env()` function directly outside of config files. Always use `config('app.name')`, not `env('APP_NAME')`.
|
||||
|
||||
### Testing
|
||||
- When creating models for tests, use the factories for the models. Check if the factory has custom states that can be used before manually setting up the model.
|
||||
- Faker: Use methods such as `$this->faker->word()` or `fake()->randomDigit()`. Follow existing conventions whether to use `$this->faker` or `fake()`.
|
||||
- When creating tests, make use of `{{ $assist->artisanCommand('make:test [options] {name}') }}` to create a feature test, and pass `--unit` to create a unit test. Most tests should be feature tests.
|
||||
|
||||
### Vite Error
|
||||
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `{{ $assist->nodePackageManagerCommand('run build') }}` or ask the user to run `{{ $assist->nodePackageManagerCommand('run dev') }}` or `{{ $assist->composerCommand('run dev') }}`.
|
||||
@@ -0,0 +1,18 @@
|
||||
## Livewire 2
|
||||
|
||||
- `wire:model` is live by default.
|
||||
- Components typically exist in the `App\Http\Livewire` namespace.
|
||||
- Use `emit()`, `emitTo()`, `emitSelf()`, and `dispatchBrowserEvent()` for events.
|
||||
- Alpine is included separately from Livewire.
|
||||
- You can listen for `livewire:load` to hook into Livewire initialization, and `Livewire.onPageExpired` for when the page expires:
|
||||
@verbatim
|
||||
<code-snippet name="Livewire Load Hook Example" lang="js">
|
||||
document.addEventListener('livewire:load', function () {
|
||||
Livewire.onPageExpired(() => {
|
||||
alert('Your session expired');
|
||||
});
|
||||
|
||||
Livewire.onError(status => console.error(status));
|
||||
});
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@@ -0,0 +1,33 @@
|
||||
## Livewire 3
|
||||
|
||||
### Key Changes From Livewire 2
|
||||
- These things changed in Livewire 3, but may not have been updated in this application. Verify this application's setup to ensure you conform with application conventions.
|
||||
- Use `wire:model.live` for real-time updates, `wire:model` is now deferred by default.
|
||||
- Components now use the `App\Livewire` namespace (not `App\Http\Livewire`).
|
||||
- Use `$this->dispatch()` to dispatch events (not `emit` or `dispatchBrowserEvent`).
|
||||
- Use the `components.layouts.app` view as the typical layout path (not `layouts.app`).
|
||||
|
||||
### New Directives
|
||||
- `wire:show`, `wire:transition`, `wire:cloak`, `wire:offline`, `wire:target` are available for use. Use the documentation to find usage examples.
|
||||
|
||||
### Alpine
|
||||
- Alpine is now included with Livewire; don't manually include Alpine.js.
|
||||
- Plugins included with Alpine: persist, intersect, collapse, and focus.
|
||||
|
||||
### Lifecycle Hooks
|
||||
- You can listen for `livewire:init` to hook into Livewire initialization, and `fail.status === 419` for the page expiring:
|
||||
@verbatim
|
||||
<code-snippet name="Livewire Init Hook Example" lang="js">
|
||||
document.addEventListener('livewire:init', function () {
|
||||
Livewire.hook('request', ({ fail }) => {
|
||||
if (fail && fail.status === 419) {
|
||||
alert('Your session expired');
|
||||
}
|
||||
});
|
||||
|
||||
Livewire.hook('message.failed', (message, component) => {
|
||||
console.error(message);
|
||||
});
|
||||
});
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@@ -0,0 +1,48 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Livewire
|
||||
|
||||
- Use the `search-docs` tool to find exact version-specific documentation for how to write Livewire and Livewire tests.
|
||||
- Use the `{{ $assist->artisanCommand('make:livewire [Posts\\CreatePost]') }}` Artisan command to create new components.
|
||||
- State should live on the server, with the UI reflecting it.
|
||||
- All Livewire requests hit the Laravel backend; they're like regular HTTP requests. Always validate form data and run authorization checks in Livewire actions.
|
||||
|
||||
## Livewire Best Practices
|
||||
- Livewire components require a single root element.
|
||||
- Use `wire:loading` and `wire:dirty` for delightful loading states.
|
||||
- Add `wire:key` in loops:
|
||||
@verbatim
|
||||
```blade
|
||||
@foreach ($items as $item)
|
||||
<div wire:key="item-{{ $item->id }}">
|
||||
{{ $item->name }}
|
||||
</div>
|
||||
@endforeach
|
||||
```
|
||||
@endverbatim
|
||||
- Prefer lifecycle hooks like `mount()`, `updatedFoo()` for initialization and reactive side effects:
|
||||
@verbatim
|
||||
<code-snippet name="Lifecycle Hook Examples" lang="php">
|
||||
public function mount(User $user) { $this->user = $user; }
|
||||
public function updatedSearch() { $this->resetPage(); }
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
|
||||
## Testing Livewire
|
||||
@verbatim
|
||||
<code-snippet name="Example Livewire Component Test" lang="php">
|
||||
Livewire::test(Counter::class)
|
||||
->assertSet('count', 0)
|
||||
->call('increment')
|
||||
->assertSet('count', 1)
|
||||
->assertSee(1)
|
||||
->assertStatus(200);
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@verbatim
|
||||
<code-snippet name="Testing Livewire Component Exists on Page" lang="php">
|
||||
$this->get('/posts/create')
|
||||
->assertSeeLivewire(CreatePost::class);
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
## Laravel MCP
|
||||
|
||||
- MCP (Model Context Protocol) is very new. You must use the `search-docs` tool to get documentation for how to write and test Laravel MCP servers, tools, resources, and prompts effectively.
|
||||
- MCP servers need to be registered with a route or handle in `routes/ai.php`. Typically, they will be registered using `Mcp::web()` to register an HTTP streaming MCP server.
|
||||
- Servers are very testable; use the `search-docs` tool to find testing instructions.
|
||||
- Do not run `mcp:start`. This command hangs waiting for JSON-RPC MCP requests.
|
||||
- Some MCP clients use Node, which has its own certificate store. If a user tries to connect to their web MCP server locally using HTTPS, it could fail due to this reason. They will need to switch to HTTP during local development.
|
||||
@@ -0,0 +1,4 @@
|
||||
## Laravel Pennant
|
||||
|
||||
- This application uses Laravel Pennant for feature flag management, providing a flexible system for controlling feature availability across different organizations and user types.
|
||||
- Use the `search-docs` tool, in combination with existing codebase conventions, to assist the user effectively with feature flags.
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
## Pest 4
|
||||
|
||||
- Pest 4 is a huge upgrade to Pest and offers: browser testing, smoke testing, visual regression testing, test sharding, and faster type coverage.
|
||||
- Browser testing is incredibly powerful and useful for this project.
|
||||
- Browser tests should live in `tests/Browser/`.
|
||||
- Use the `search-docs` tool for detailed guidance on utilizing these features.
|
||||
|
||||
### Browser Testing
|
||||
- You can use Laravel features like `Event::fake()`, `assertAuthenticated()`, and model factories within Pest 4 browser tests, as well as `RefreshDatabase` (when needed) to ensure a clean state for each test.
|
||||
- Interact with the page (click, type, scroll, select, submit, drag-and-drop, touch gestures, etc.) when appropriate to complete the test.
|
||||
- If requested, test on multiple browsers (Chrome, Firefox, Safari).
|
||||
- If requested, test on different devices and viewports (like iPhone 14 Pro, tablets, or custom breakpoints).
|
||||
- Switch color schemes (light/dark mode) when appropriate.
|
||||
- Take screenshots or pause tests for debugging when appropriate.
|
||||
|
||||
### Example Tests
|
||||
@verbatim
|
||||
<code-snippet name="Pest Browser Test Example" lang="php">
|
||||
it('may reset the password', function () {
|
||||
Notification::fake();
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
$page = visit('/sign-in'); // Visit on a real browser...
|
||||
|
||||
$page->assertSee('Sign In')
|
||||
->assertNoJavascriptErrors() // or ->assertNoConsoleLogs()
|
||||
->click('Forgot Password?')
|
||||
->fill('email', 'nuno@laravel.com')
|
||||
->click('Send Reset Link')
|
||||
->assertSee('We have emailed your password reset link!')
|
||||
|
||||
Notification::assertSent(ResetPassword::class);
|
||||
});
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
|
||||
@verbatim
|
||||
<code-snippet name="Pest Smoke Testing Example" lang="php">
|
||||
$pages = visit(['/', '/about', '/contact']);
|
||||
|
||||
$pages->assertNoJavascriptErrors()->assertNoConsoleLogs();
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
## Pest
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
### Testing
|
||||
- If you need to verify a feature is working, write or update a Unit / Feature test.
|
||||
|
||||
### Pest Tests
|
||||
- All tests must be written using Pest. Use `{{ $assist->artisanCommand('make:test --pest {name}') }}`.
|
||||
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files - these are core to the application.
|
||||
- Tests should test all of the happy paths, failure paths, and weird paths.
|
||||
- Tests live in the `tests/Feature` and `tests/Unit` directories.
|
||||
- Pest tests look and behave like this:
|
||||
<code-snippet name="Basic Pest Test Example" lang="php">
|
||||
it('is true', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
</code-snippet>
|
||||
|
||||
### Running Tests
|
||||
- Run the minimal number of tests using an appropriate filter before finalizing code edits.
|
||||
- To run all tests: `{{ $assist->artisanCommand('test --compact') }}`.
|
||||
- To run all tests in a file: `{{ $assist->artisanCommand('test --compact tests/Feature/ExampleTest.php') }}`.
|
||||
- To filter on a particular test name: `{{ $assist->artisanCommand('test --compact --filter=testName') }}` (recommended after making a change to a related file).
|
||||
- When the tests relating to your changes are passing, ask the user if they would like to run the entire test suite to ensure everything is still passing.
|
||||
|
||||
### Pest Assertions
|
||||
- When asserting status codes on a response, use the specific method like `assertForbidden` and `assertNotFound` instead of using `assertStatus(403)` or similar, e.g.:
|
||||
<code-snippet name="Pest Example Asserting postJson Response" lang="php">
|
||||
it('returns all', function () {
|
||||
$response = $this->postJson('/api/docs', []);
|
||||
|
||||
$response->assertSuccessful();
|
||||
});
|
||||
</code-snippet>
|
||||
|
||||
### Mocking
|
||||
- Mocking can be very helpful when appropriate.
|
||||
- When mocking, you can use the `Pest\Laravel\mock` Pest function, but always import it via `use function Pest\Laravel\mock;` before using it. Alternatively, you can use `$this->mock()` if existing tests do.
|
||||
- You can also create partial mocks using the same import or self method.
|
||||
|
||||
### Datasets
|
||||
- Use datasets in Pest to simplify tests that have a lot of duplicated data. This is often the case when testing validation rules, so consider this solution when writing tests for validation rules.
|
||||
|
||||
<code-snippet name="Pest Dataset Example" lang="php">
|
||||
it('has emails', function (string $email) {
|
||||
expect($email)->not->toBeEmpty();
|
||||
})->with([
|
||||
'james' => 'james@laravel.com',
|
||||
'taylor' => 'taylor@laravel.com',
|
||||
]);
|
||||
</code-snippet>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
## PHP 8.4
|
||||
|
||||
- PHP 8.4 has new array functions that will make code simpler whenever we don't use Laravel's collections:
|
||||
- `array_find(array $array, callable $callback): mixed` - Find first matching element.
|
||||
- `array_find_key(array $array, callable $callback): int|string|null` - Find first matching key.
|
||||
- `array_any(array $array, callable $callback): bool` - Check if any element satisfies a callback function.
|
||||
- `array_all(array $array, callable $callback): bool` - Check if all elements satisfy a callback function.
|
||||
|
||||
### Cleaner Chaining on New Instances
|
||||
- No extra parentheses are needed when chaining on new object instances:
|
||||
|
||||
<code-snippet name="New Object Chaining Example" lang="php">
|
||||
// Before PHP 8.4
|
||||
$response = (new JsonResponse(['data' => $data]))->setStatusCode(201);
|
||||
|
||||
// After PHP 8.4
|
||||
$response = new JsonResponse(['data' => $data])->setStatusCode(201);
|
||||
</code-snippet>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
## PHP 8.5
|
||||
|
||||
- PHP 8.5 has new array functions that will make code simpler whenever we don't use Laravel's collections:
|
||||
- `array_first(array $array): mixed` - Get first value (or `null` if empty).
|
||||
- `array_last(array $array): mixed` - Get last value (or `null` if empty).
|
||||
|
||||
- Use `clone($object, ['property' => $value])` to modify properties during cloning; this is ideal for readonly classes.
|
||||
|
||||
### Pipe Operator
|
||||
- The pipe operator (`|>`) chains function calls left-to-right, replacing nested calls:
|
||||
<code-snippet name="Pipe Operator Example" lang="php">
|
||||
// Before PHP 8.5
|
||||
$slug = strtolower(str_replace(' ', '-', trim($title)));
|
||||
|
||||
// After PHP 8.5
|
||||
$slug = $title |> trim(...) |> (fn($s) => str_replace(' ', '-', $s)) |> strtolower(...);
|
||||
</code-snippet>
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
## PHP
|
||||
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
@if($assist->shouldEnforceStrictTypes())
|
||||
- Always use strict typing at the head of a `.php` file: `declare(strict_types=1);`.
|
||||
@endif
|
||||
- Always use curly braces for control structures, even if it has one line.
|
||||
|
||||
### Constructors
|
||||
- Use PHP 8 constructor property promotion in `__construct()`.
|
||||
- <code-snippet>public function __construct(public GitHub $github) { }</code-snippet>
|
||||
- Do not allow empty `__construct()` methods with zero parameters unless the constructor is private.
|
||||
|
||||
### Type Declarations
|
||||
- Always use explicit return type declarations for methods and functions.
|
||||
- Use appropriate PHP type hints for method parameters.
|
||||
|
||||
<code-snippet name="Explicit Return Types and Method Params" lang="php">
|
||||
protected function isAccessible(User $user, ?string $path = null): bool
|
||||
{
|
||||
...
|
||||
}
|
||||
</code-snippet>
|
||||
|
||||
## Comments
|
||||
- Prefer PHPDoc blocks over inline comments. Never use comments within the code itself unless there is something very complex going on.
|
||||
|
||||
## PHPDoc Blocks
|
||||
- Add useful array shape type definitions for arrays when appropriate.
|
||||
|
||||
## Enums
|
||||
@if(empty($assist->enums()) || preg_match('/[A-Z]{3,8}/', $assist->enumContents()))
|
||||
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
|
||||
@else
|
||||
- That being said, keys in an Enum should follow existing application Enum conventions.
|
||||
@endif
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## PHPUnit
|
||||
|
||||
- This application uses PHPUnit for testing. All tests must be written as PHPUnit classes. Use `{{ $assist->artisanCommand('make:test --phpunit {name}') }}` to create a new test.
|
||||
- If you see a test using "Pest", convert it to PHPUnit.
|
||||
- Every time a test has been updated, run that singular test.
|
||||
- When the tests relating to your feature are passing, ask the user if they would like to also run the entire test suite to make sure everything is still passing.
|
||||
- Tests should test all of the happy paths, failure paths, and weird paths.
|
||||
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files; these are core to the application.
|
||||
|
||||
### Running Tests
|
||||
- Run the minimal number of tests, using an appropriate filter, before finalizing.
|
||||
- To run all tests: `{{ $assist->artisanCommand('test --compact') }}`.
|
||||
- To run all tests in a file: `{{ $assist->artisanCommand('test --compact tests/Feature/ExampleTest.php') }}`.
|
||||
- To filter on a particular test name: `{{ $assist->artisanCommand('test --compact --filter=testName') }}` (recommended after making a change to a related file).
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Laravel Pint Code Formatter
|
||||
|
||||
@if($assist->supportsPintAgentFormatter())
|
||||
- You must run `{{ $assist->binCommand('pint') }} --dirty --format agent` before finalizing changes to ensure your code matches the project's expected style.
|
||||
- Do not run `{{ $assist->binCommand('pint') }} --test --format agent`, simply run `{{ $assist->binCommand('pint') }} --format agent` to fix any formatting issues.
|
||||
@else
|
||||
- You must run `{{ $assist->binCommand('pint') }} --dirty` before finalizing changes to ensure your code matches the project's expected style.
|
||||
- Do not run `{{ $assist->binCommand('pint') }} --test`, simply run `{{ $assist->binCommand('pint') }}` to fix any formatting issues.
|
||||
@endif
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Laravel Sail
|
||||
|
||||
- This project runs inside Laravel Sail's Docker containers. You MUST execute all commands through Sail.
|
||||
- Start services using `{{ $assist->sailBinaryPath() }} up -d` and stop them with `{{ $assist->sailBinaryPath() }} stop`.
|
||||
- Open the application in the browser by running `{{ $assist->sailBinaryPath() }} open`.
|
||||
- Always prefix PHP, Artisan, Composer, and Node commands with `{{ $assist->sailBinaryPath() }}`. Examples:
|
||||
- Run Artisan Commands: `{{ $assist->artisanCommand('migrate') }}`
|
||||
- Install Composer packages: `{{ $assist->composerCommand('install') }}`
|
||||
- Execute Node commands: `{{ $assist->nodePackageManagerCommand('run dev') }}`
|
||||
- Execute PHP scripts: `{{ $assist->sailBinaryPath() }} php [script]`
|
||||
- View all available Sail commands by running `{{ $assist->sailBinaryPath() }}` without arguments.
|
||||
@@ -0,0 +1,3 @@
|
||||
## Tailwind CSS 3
|
||||
|
||||
- Always use Tailwind CSS v3; verify you're using only classes supported by this version.
|
||||
@@ -0,0 +1,39 @@
|
||||
## Tailwind CSS 4
|
||||
|
||||
- Always use Tailwind CSS v4; do not use the deprecated utilities.
|
||||
- `corePlugins` is not supported in Tailwind v4.
|
||||
- In Tailwind v4, configuration is CSS-first using the `@theme` directive — no separate `tailwind.config.js` file is needed.
|
||||
@verbatim
|
||||
<code-snippet name="Extending Theme in CSS" lang="css">
|
||||
@theme {
|
||||
--color-brand: oklch(0.72 0.11 178);
|
||||
}
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
- In Tailwind v4, you import Tailwind using a regular CSS `@import` statement, not using the `@tailwind` directives used in v3:
|
||||
@verbatim
|
||||
<code-snippet name="Tailwind v4 Import Tailwind Diff" lang="diff">
|
||||
- @tailwind base;
|
||||
- @tailwind components;
|
||||
- @tailwind utilities;
|
||||
+ @import "tailwindcss";
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
|
||||
### Replaced Utilities
|
||||
- Tailwind v4 removed deprecated utilities. Do not use the deprecated option; use the replacement.
|
||||
- Opacity values are still numeric.
|
||||
|
||||
| Deprecated | Replacement |
|
||||
|------------+--------------|
|
||||
| bg-opacity-* | bg-black/* |
|
||||
| text-opacity-* | text-black/* |
|
||||
| border-opacity-* | border-black/* |
|
||||
| divide-opacity-* | divide-black/* |
|
||||
| ring-opacity-* | ring-black/* |
|
||||
| placeholder-opacity-* | placeholder-black/* |
|
||||
| flex-shrink-* | shrink-* |
|
||||
| flex-grow-* | grow-* |
|
||||
| overflow-ellipsis | text-ellipsis |
|
||||
| decoration-slice | box-decoration-slice |
|
||||
| decoration-clone | box-decoration-clone |
|
||||
@@ -0,0 +1,21 @@
|
||||
## Tailwind CSS
|
||||
|
||||
- Use Tailwind CSS classes to style HTML; check and use existing Tailwind conventions within the project before writing your own.
|
||||
- Offer to extract repeated patterns into components that match the project's conventions (i.e. Blade, JSX, Vue, etc.).
|
||||
- Think through class placement, order, priority, and defaults. Remove redundant classes, add classes to parent or child carefully to limit repetition, and group elements logically.
|
||||
- You can use the `search-docs` tool to get exact examples from the official documentation when needed.
|
||||
|
||||
### Spacing
|
||||
- When listing items, use gap utilities for spacing; don't use margins.
|
||||
@verbatim
|
||||
<code-snippet name="Valid Flex Gap Spacing Example" lang="html">
|
||||
<div class="flex gap-8">
|
||||
<div>Superior</div>
|
||||
<div>Michigan</div>
|
||||
<div>Erie</div>
|
||||
</div>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
|
||||
### Dark Mode
|
||||
- If existing pages and components support dark mode, new pages and components must support dark mode in a similar way, typically using `dark:`.
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Livewire Volt
|
||||
|
||||
- This project uses Livewire Volt for interactivity within its pages. New pages requiring interactivity must also use Livewire Volt.
|
||||
- Make new Volt components using `{{ $assist->artisanCommand('make:volt [name] [--test] [--pest]') }}`.
|
||||
- Volt is a class-based and functional API for Livewire that supports single-file components, allowing a component's PHP logic and Blade templates to coexist in the same file.
|
||||
- Livewire Volt allows PHP logic and Blade templates in one file. Components use the @verbatim`@volt`@endverbatim directive.
|
||||
- You must check existing Volt components to determine if they're functional or class-based. If you can't detect that, ask the user which they prefer before writing a Volt component.
|
||||
|
||||
### Volt Functional Component Example
|
||||
@verbatim
|
||||
<code-snippet name="Volt Functional Component Example" lang="php">
|
||||
@volt
|
||||
<?php
|
||||
use function Livewire\Volt\{state, computed};
|
||||
|
||||
state(['count' => 0]);
|
||||
|
||||
$increment = fn () => $this->count++;
|
||||
$decrement = fn () => $this->count--;
|
||||
|
||||
$double = computed(fn () => $this->count * 2);
|
||||
?>
|
||||
|
||||
<div>
|
||||
<h1>Count: {{ $count }}</h1>
|
||||
<h2>Double: {{ $this->double }}</h2>
|
||||
<button wire:click="increment">+</button>
|
||||
<button wire:click="decrement">-</button>
|
||||
</div>
|
||||
@endvolt
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
### Volt Class Based Component Example
|
||||
To get started, define an anonymous class that extends Livewire\Volt\Component. Within the class, you may utilize all of the features of Livewire using traditional Livewire syntax:
|
||||
@verbatim
|
||||
<code-snippet name="Volt Class-based Volt Component Example" lang="php">
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new class extends Component {
|
||||
public $count = 0;
|
||||
|
||||
public function increment()
|
||||
{
|
||||
$this->count++;
|
||||
}
|
||||
} ?>
|
||||
|
||||
<div>
|
||||
<h1>{{ $count }}</h1>
|
||||
<button wire:click="increment">+</button>
|
||||
</div>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
### Testing Volt & Volt Components
|
||||
- Use the existing directory for tests if it already exists. Otherwise, fallback to `tests/Feature/Volt`.
|
||||
|
||||
<code-snippet name="Livewire Test Example" lang="php">
|
||||
use Livewire\Volt\Volt;
|
||||
|
||||
test('counter increments', function () {
|
||||
Volt::test('counter')
|
||||
->assertSee('Count: 0')
|
||||
->call('increment')
|
||||
->assertSee('Count: 1');
|
||||
});
|
||||
</code-snippet>
|
||||
@verbatim
|
||||
<code-snippet name="Volt Component Test Using Pest" lang="php">
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Models\{User, Product};
|
||||
use Livewire\Volt\Volt;
|
||||
|
||||
test('product form creates product', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
Volt::test('pages.products.create')
|
||||
->actingAs($user)
|
||||
->set('form.name', 'Test Product')
|
||||
->set('form.description', 'Test Description')
|
||||
->set('form.price', 99.99)
|
||||
->call('create')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect(Product::where('name', 'Test Product')->exists())->toBeTrue();
|
||||
});
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
### Common Patterns
|
||||
@verbatim
|
||||
<code-snippet name="CRUD With Volt" lang="php">
|
||||
<?php
|
||||
|
||||
use App\Models\Product;
|
||||
use function Livewire\Volt\{state, computed};
|
||||
|
||||
state(['editing' => null, 'search' => '']);
|
||||
|
||||
$products = computed(fn() => Product::when($this->search,
|
||||
fn($q) => $q->where('name', 'like', "%{$this->search}%")
|
||||
)->get());
|
||||
|
||||
$edit = fn(Product $product) => $this->editing = $product->id;
|
||||
$delete = fn(Product $product) => $product->delete();
|
||||
|
||||
?>
|
||||
|
||||
<!-- HTML / UI Here -->
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@verbatim
|
||||
<code-snippet name="Real-Time Search With Volt" lang="php">
|
||||
<flux:input
|
||||
wire:model.live.debounce.300ms="search"
|
||||
placeholder="Search..."
|
||||
/>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@verbatim
|
||||
<code-snippet name="Loading States With Volt" lang="php">
|
||||
<flux:button wire:click="save" wire:loading.attr="disabled">
|
||||
<span wire:loading.remove>Save</span>
|
||||
<span wire:loading>Saving...</span>
|
||||
</flux:button>
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
@@ -0,0 +1,79 @@
|
||||
@php
|
||||
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
|
||||
@endphp
|
||||
## Laravel Wayfinder
|
||||
|
||||
Wayfinder generates TypeScript functions and types for Laravel controllers and routes which you can import into your client-side code. It provides type safety and automatic synchronization between backend routes and frontend code.
|
||||
|
||||
### Development Guidelines
|
||||
- Always use the `search-docs` tool to check Wayfinder correct usage before implementing any features.
|
||||
- Always prefer named imports for tree-shaking (e.g., `import { show } from '@/actions/...'`).
|
||||
- Avoid default controller imports (prevents tree-shaking).
|
||||
- Run `{{ $assist->artisanCommand('wayfinder:generate') }}` after route changes if Vite plugin isn't installed.
|
||||
|
||||
### Feature Overview
|
||||
- Form Support: Use `.form()` with `--with-form` flag for HTML form attributes — `<form {...store.form()}>` → `action="/posts" method="post"`.
|
||||
- HTTP Methods: Call `.get()`, `.post()`, `.patch()`, `.put()`, `.delete()` for specific methods — `show.head(1)` → `{ url: "/posts/1", method: "head" }`.
|
||||
- Invokable Controllers: Import and invoke directly as functions. For example, `import StorePost from '@/actions/.../StorePostController'; StorePost()`.
|
||||
- Named Routes: Import from `@/routes/` for non-controller routes. For example, `import { show } from '@/routes/post'; show(1)` for route name `post.show`.
|
||||
- Parameter Binding: Detects route keys (e.g., `{post:slug}`) and accepts matching object properties — `show("my-post")` or `show({ slug: "my-post" })`.
|
||||
- Query Merging: Use `mergeQuery` to merge with `window.location.search`, set values to `null` to remove — `show(1, { mergeQuery: { page: 2, sort: null } })`.
|
||||
- Query Parameters: Pass `{ query: {...} }` in options to append params — `show(1, { query: { page: 1 } })` → `"/posts/1?page=1"`.
|
||||
- Route Objects: Functions return `{ url, method }` shaped objects — `show(1)` → `{ url: "/posts/1", method: "get" }`.
|
||||
- URL Extraction: Use `.url()` to get URL string — `show.url(1)` → `"/posts/1"`.
|
||||
|
||||
### Example Usage
|
||||
@verbatim
|
||||
<code-snippet name="Wayfinder Basic Usage" lang="typescript">
|
||||
// Import controller methods (tree-shakable)...
|
||||
import { show, store, update } from '@/actions/App/Http/Controllers/PostController'
|
||||
|
||||
// Get route object with URL and method...
|
||||
show(1) // { url: "/posts/1", method: "get" }
|
||||
|
||||
// Get just the URL...
|
||||
show.url(1) // "/posts/1"
|
||||
|
||||
// Use specific HTTP methods...
|
||||
show.get(1) // { url: "/posts/1", method: "get" }
|
||||
show.head(1) // { url: "/posts/1", method: "head" }
|
||||
|
||||
// Import named routes...
|
||||
import { show as postShow } from '@/routes/post' // For route name 'post.show'
|
||||
postShow(1) // { url: "/posts/1", method: "get" }
|
||||
</code-snippet>
|
||||
@endverbatim
|
||||
|
||||
@if($assist->roster->uses(\Laravel\Roster\Enums\Packages::INERTIA_LARAVEL) || $assist->roster->uses(\Laravel\Roster\Enums\Packages::INERTIA_REACT) || $assist->roster->uses(\Laravel\Roster\Enums\Packages::INERTIA_VUE) || $assist->roster->uses(\Laravel\Roster\Enums\Packages::INERTIA_SVELTE))
|
||||
### Wayfinder + Inertia
|
||||
@if($assist->inertia()->hasFormComponent())
|
||||
If your application uses the `<Form>` component from Inertia, you can use Wayfinder to generate form action and method automatically.
|
||||
@if($assist->roster->uses(\Laravel\Roster\Enums\Packages::INERTIA_REACT))
|
||||
@boostsnippet("Wayfinder Form Component (React)", "typescript")
|
||||
<Form {...store.form()}><input name="title" /></Form>
|
||||
@endboostsnippet
|
||||
@endif
|
||||
@if($assist->roster->uses(\Laravel\Roster\Enums\Packages::INERTIA_VUE))
|
||||
@boostsnippet("Wayfinder Form Component (Vue)", "vue")
|
||||
<Form v-bind="store.form()"><input name="title" /></Form>
|
||||
@endboostsnippet
|
||||
@endif
|
||||
@if($assist->roster->uses(\Laravel\Roster\Enums\Packages::INERTIA_SVELTE))
|
||||
@boostsnippet("Wayfinder Form Component (Svelte)", "svelte")
|
||||
<Form {...store.form()}><input name="title" /></Form>
|
||||
@endboostsnippet
|
||||
@endif
|
||||
@else
|
||||
If your application uses the `useForm` component from Inertia, you can directly submit to the Wayfinder generated functions.
|
||||
|
||||
<code-snippet name="Wayfinder useForm Example" lang="typescript">
|
||||
import { store } from "@/actions/App/Http/Controllers/ExampleController";
|
||||
|
||||
const form = useForm({
|
||||
name: "My Big Post",
|
||||
});
|
||||
|
||||
form.submit(store());
|
||||
</code-snippet>
|
||||
@endif
|
||||
@endif
|
||||
Reference in New Issue
Block a user