Install commands | laravel-package-tools-rust | Spatie       

 SPATIE  

laravel-package-tools-rust
==========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-package-tools-rust](https://spatie.be/docs/laravel-package-tools-rust/v1)  Install commands

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-package-tools-rust/v1) 

  Install commands    
- [ Introduction ](https://spatie.be/docs/laravel-package-tools-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-package-tools-rust/v1/support-us)
- [ Installation ](https://spatie.be/docs/laravel-package-tools-rust/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-package-tools-rust/v1/usage)
- [ Install commands ](https://spatie.be/docs/laravel-package-tools-rust/v1/install-commands)
- [ Changelog ](https://spatie.be/docs/laravel-package-tools-rust/v1/changelog)
- [ Testing ](https://spatie.be/docs/laravel-package-tools-rust/v1/testing)

 Install commands
================

An install command belongs to the package. Define a typed native command and register it with `.install_command::<Install>()`. Its clap definition owns the name and options; package tools does not infer a name or install providers into application source files.

Use `InstallCommand` to run named asynchronous steps in order:

```
use laravel::console::{Console, clap};
use spatie_package_tools::{InstallCommand, Package};

#[derive(clap::Parser)]
#[command(name = "my-package:install")]
struct Install;

#[laravel::console::command]
impl Install {
    async fn handle(self, console: &mut Console) -> laravel::Result<()> {
        InstallCommand::new("my-package")
            .step("Welcome", |console| Box::pin(async move {
                console.line("Installing my-package");
                Ok(())
            }))
            .step("Application", |console| Box::pin(async move {
                console.line(format!("Application: {}", laravel::config::config().app.name));
                Ok(())
            }))
            .run(console)
            .await
    }
}

let app = laravel::Application::configure()
    .replace_env(laravel::config::Env::default())
    .with_providers(|providers| {
        providers.add(Package::new("my-package").install_command::<Install>());
    })
    .create();
```

- Registration and application boot never run installation steps.
- Each step receives the native console, including its prompt and non-interactive behavior.
- Steps run inside the command's application context, so they can resolve services through native APIs.
- The first error propagates unchanged and prevents later steps and the completion message.
- Earlier successful steps are not rolled back. Make retryable steps idempotent where possible.
- Destructive actions and migrations must be explicit decisions in your command, with appropriate confirmation or flags. No migration, resource overwrite or network request is added automatically.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
