Skip to content

Artisan commands

Lattice registers its commands under the lattice namespace. Inspect the current list in an application with:

Terminal window
php artisan list lattice

These commands create PHP-only definition classes under app/. Each accepts a required name argument and --force to overwrite an existing file.

CommandWrites toBase class
php artisan lattice:page Homeapp/PagesPage
php artisan lattice:form Contactapp/FormsFormDefinition
php artisan lattice:table Usersapp/TablesEloquentTableDefinition
php artisan lattice:action Saveapp/ActionsActionDefinition
php artisan lattice:bulk-action Exportapp/ActionsBulkActionDefinition
php artisan lattice:fragment Statsapp/FragmentsFragmentDefinition
php artisan lattice:layout Appapp/LayoutsLayoutDefinition
php artisan lattice:remote-source Searchapp/RemoteRemoteSourceDefinition

Nested names create nested namespaces and directories:

Terminal window
php artisan lattice:form Settings/ProfileForm

That writes app/Forms/Settings/ProfileForm.php with the namespace App\Forms\Settings.

These commands create both the PHP class and the React renderer, then append the registration to resources/js/registry.ts.

CommandPHP fileReact fileRegistry block
php artisan lattice:field ColorPickerapp/Forms/Fieldsresources/js/fields/color-picker.tsxcomponents
php artisan lattice:component Ratingapp/Componentsresources/js/components/rating.tsxcomponents
php artisan lattice:column StatusBadgeapp/Tables/Columnsresources/js/columns/status-badge.tsxcolumns

Publish the registry scaffold before running them:

Terminal window
php artisan vendor:publish --tag=lattice-js

All three accept:

OptionPurpose
--type=Override the derived type string.
--forceOverwrite generated files that already exist. Existing registry entries are not duplicated.

By default, ColorPicker becomes field.color-picker, Rating becomes rating, and StatusBadge becomes column.status-badge. The commands run lattice:typescript after updating the registry so the renderer props are narrowed immediately.

Run the TypeScript generator when custom Lattice classes gain or lose public props:

Terminal window
php artisan lattice:typescript

It scans config('lattice.discover'), reads the discovered component, field, and column classes, and writes the declaration file configured at config('lattice.typescript.output') (resources/js/lattice/generated.d.ts by default). The generated file augments the configured module (@lattice-php/lattice by default), so node.props and column.props stay typed on the client.

lattice:typescript requires spatie/typescript-transformer. Install it as a dev dependency in applications that use the generator.

Discovery scans the configured paths for Lattice attributes. Cache that manifest for production:

Terminal window
php artisan lattice:discover-cache

Clear it when the discovered classes or paths change:

Terminal window
php artisan lattice:discover-clear

Lattice also registers these with Laravel’s optimization flow, so the cache command runs with php artisan optimize and the clear command runs with php artisan optimize:clear.

Terminal window
php artisan vendor:publish --tag=lattice-config
php artisan vendor:publish --tag=lattice-js
php artisan lattice:page Dashboard
php artisan lattice:form Settings/ProfileForm
php artisan lattice:field ColorPicker --type=color-picker
php artisan lattice:typescript

Use the registry and types page for the generated React registry, and configuration for the discover and typescript settings these commands read.