Public/Build-LumenApi.ps1

function Build-LumenApi {
    <#
        .SYNOPSIS
            Update a PHP/Lumen API application.
        .DESCRIPTION
            Wraps Invoke-WebAppUpdate with Lumen-specific build steps:
            - Production: composer install --no-dev -o + artisan config:clear
            - Development (develop branch): composer install (with dev dependencies)
        .PARAMETER Directory
            Path to the Lumen application directory.
        .PARAMETER Branch
            Git branch name. When 'develop', uses dev composer install.
        .PARAMETER Alias
            Display name for the application.
        .PARAMETER Url
            The application URL (for display purposes).
        .PARAMETER MutexName
            Mutex name for single-execution guard.
        .PARAMETER Force
            If set, always reset and pull.
        .PARAMETER LogFile
            Path to the log file.
        .PARAMETER SmtpServer
            SMTP server for notifications.
        .PARAMETER SmtpFrom
            Sender address for notifications.
        .PARAMETER To
            Recipient(s) for notifications.
        .PARAMETER Cc
            CC recipient(s) for notifications.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]  [string]$Directory,
        [Parameter(Mandatory = $true)]  [string]$Branch,
        [Parameter(Mandatory = $true)]  [string]$Alias,
        [Parameter(Mandatory = $true)]  [string]$Url,
        [Parameter(Mandatory = $false)] [string]$MutexName = 'WebAppUpdateMutex',
        [Parameter(Mandatory = $false)] [switch]$Force,
        [Parameter(Mandatory = $false)] [string]$LogFile,
        [Parameter(Mandatory = $false)] [string]$SmtpServer,
        [Parameter(Mandatory = $false)] [string]$SmtpFrom,
        [Parameter(Mandatory = $false)] [string[]]$To,
        [Parameter(Mandatory = $false)] [string[]]$Cc
    )
    Process {
        $arguments = @{}
        foreach ($key in $PSBoundParameters.Keys) { $arguments[$key] = $PSBoundParameters[$key] }
        $arguments['ScriptBlock'] = [ordered]@{
            Building   = {
                Write-Verbose '> Building Lumen for Production'
                composer install --no-ansi --prefer-dist --no-dev -o 2>&1
            }
            Optimizing = {
                Write-Verbose '> Optimizing'
                php artisan config:clear 2>&1
            }
        }
        if ($Branch -eq 'develop') {
            $arguments['ScriptBlock']['Building'] = {
                Write-Verbose '> Building Lumen for Development'
                composer install 2>&1
            }
        }
        Invoke-WebAppUpdate @arguments
    }
}