我尝试通过运行在 PowerShell 中设置别名Set-Alias -Name artisan -Value 'php aritsan'
,虽然命令运行成功,但是当我调用别名时,出现以下错误:
artisan : The term 'php aritsan' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ artisan
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (php aritsan:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
正确的方法是什么?
P.S: artisan
是当前目录中的一个文件。该文件是用laravel框架打包的
这将帮助您在 Windows PowerShell 中全局创建“php artisan”的别名。
只需按照以下步骤操作即可完成。
-
首先使用win+S搜索powershell并以管理员身份运行,然后粘贴此代码并按Enter键。
if (!(Test-Path -Path $PROFILE )) {New-Item -Type File -Path $PROFILE -Force }
-
然后运行这个命令。
记事本$配置文件
-
将打开一个记事本文件。将此代码粘贴到记事本文件中,然后按 ctrl+S
函数 CD32($arg1,$arg2,$arg3,$arg4,$arg5) {php 工匠 $arg1 $arg2 $arg3 $arg4 $arg5}
设置别名-名称 pa -值 CD32
-
最后将此命令粘贴到您的 powershell 上并按 Enter 键。
设置-ExecutionPolicy -ExecutionPolicy RemoteSigned
一切都完成了。现在,您可以在 Windows powershell 中全局使用“pa”作为“php artisan”的别名。
在这里,我在 VS Code PowerShell 上使用“pa”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)