amsiam / lara-ui-cli
CLI tool for installing LaraUI components in Laravel projects
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.0
- illuminate/console: ^11.0|^12.0
- illuminate/filesystem: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.0
README
A CLI tool for adding LaraUI components to your Laravel project. Similar to shadcn/ui CLI, this tool fetches components from the LaraUI registry and installs them directly into your project.
Installation
composer require amsiam/lara-ui-cli --dev
Quick Start
1. Initialize your project
php artisan ui:init
This will:
- Create a
lara-ui.jsonconfiguration file - Install CSS variables to
resources/css/lara-ui.css - Update your
app.cssto import the styles
2. Add components
# Add specific components php artisan ui:add button card input # Add all components php artisan ui:add all # Interactive selection php artisan ui:add
3. Use components
<x-ui::button variant="primary">Click me</x-ui::button> <x-ui::card> <x-ui::card-header> <x-ui::card-title>Hello</x-ui::card-title> </x-ui::card-header> <x-ui::card-content> Content here </x-ui::card-content> </x-ui::card>
Commands
ui:init
Initialize LaraUI in your project.
php artisan ui:init [--force] [--yes] [--registry=]
| Option | Description |
|---|---|
--force |
Overwrite existing configuration |
--yes |
Skip prompts, use defaults |
--registry= |
Custom registry URL (default: GitHub) |
Examples:
# Default initialization (uses official LaraUI registry) php artisan ui:init # Use custom registry php artisan ui:init --registry=https://your-domain.com/components # Quick setup with defaults php artisan ui:init --yes # Custom registry with defaults php artisan ui:init --yes --registry=http://localhost:8000/packages/laraui
ui:add
Add components to your project.
php artisan ui:add [components...] [--all] [--force] [--deps] [--path=]
| Option | Description |
|---|---|
--all |
Install all available components |
--force |
Overwrite existing files |
--deps |
Skip dependency installation |
--path= |
Custom installation path |
Examples:
# Add specific components php artisan ui:add button card dialog # Add all components php artisan ui:add all # Interactive multi-select php artisan ui:add # Force overwrite existing php artisan ui:add button --force # Custom path php artisan ui:add button --path=resources/ui
ui:list
List available components.
php artisan ui:list [--category=] [--installed] [--available] [--json] [--refresh]
| Option | Description |
|---|---|
--category= |
Filter by category (core, forms, feedback, etc.) |
--installed |
Show only installed components |
--available |
Show only not-installed components |
--json |
Output as JSON |
--refresh |
Refresh the registry cache |
ui:diff
Check for updates to installed components.
php artisan ui:diff [component] [--all]
| Option | Description |
|---|---|
component |
Specific component to check |
--all |
Check all installed components |
Configuration
After running ui:init, a lara-ui.json file is created in your project root:
{
"registry": "https://raw.githubusercontent.com/amsiam/lara-ui/main",
"aliases": {
"components": "resources/views/components/ui",
"utils": "app/View/Components/LaraUi"
},
"tailwind": {
"css": "resources/css/app.css"
},
"prefix": "ui"
}
Configuration Options
| Key | Description | Default |
|---|---|---|
registry |
URL of the component registry | GitHub raw URL |
aliases.components |
Where Blade views are installed | resources/views/components/ui |
aliases.utils |
Where PHP classes are installed | app/View/Components/LaraUi |
tailwind.css |
Path to your main CSS file | resources/css/app.css |
prefix |
Component prefix (e.g., x-ui::) |
ui |
Custom Registry
You can host your own component registry by setting the registry URL:
{
"registry": "https://your-domain.com/lara-ui"
}
The registry must have a registry.json file and the component files at the expected paths.
How It Works
-
Initialization (
ui:init)- Creates configuration file
- Downloads CSS variables from registry
- Sets up your project for LaraUI
-
Adding Components (
ui:add)- Fetches component files from the registry (GitHub)
- Resolves and installs dependencies automatically
- Transforms namespaces and prefixes for your project
- Copies files to your configured paths
-
Component Ownership
- Components are copied to your project
- You own and can customize them fully
- No runtime dependency on the registry
Requirements
- PHP 8.2+
- Laravel 11 or 12
- Tailwind CSS 4
- Alpine.js 3.x (for interactive components)
Dependencies
After installing components, ensure you have these packages:
# Required for class merging
composer require gehrisandro/tailwind-merge-laravel
License
MIT License