Create alias in Windows Powershell

To solve this, you need to create a PowerShell function instead, and then create an alias for that function. Here’s how to do it:

# Create a function that runs your phpcs command
function Check-PHPErrors {
    & ./vendor/bin/phpcs --warning-severity=0 -s --ignore-annotations --extensions=php,html ./
}

# Create an alias for the function
Set-Alias -Name check-errors -Value Check-PHPErr

To make this permanent, you should add these lines to your PowerShell profile. Here’s how:

  1. First, check if you already have a profile:
Test-Path $PROFILE

2. If it returns False, create a new profile:

New-Item -Path $PROFILE -Type File -Force

3. Open the profile in a text editor:

notepad $PROFILE

4. Add the function and alias definition to your profile, save, and close.

5. Reload your profile:

. $PROFILE

Paste this in PowerShell profile file

# Create a function that runs your phpcs command
function Check-PHPErrors {
    & ./vendor/bin/phpcs --warning-severity=0 -s --ignore-annotations --extensions=php,html ./
}

# Create an alias for the function
Set-Alias -Name check-errors -Value Check-PHPErrors

# Create a function that runs your phpcs command
function Fix-PHPErrors {
    & ./vendor/bin/phpcbf --warning-severity=0 -s --ignore-annotations --extensions=php,html ./
}

# Create an alias for the function
Set-Alias -Name fix-errors -Value Fix-PHPErrors