5

I try to run Laravel's Artisan command inside the (docker) container by defining a doskey alias.

My idea was:

php artisan=docker-compose exec apache php artisan $1

However it does not allow me to use a space in the key. Any idea how to achieve this?

 image showing "invalid macro definition" error

edit I have made a little GUI tool for Windows to run the commands https://github.com/thomasmoors/DockerArtisan

5
+50

I must in this case give a negative answer - using blanks in a doskey name is impossible. Doskey was created for the Command Prompt (cmd), so is rather simple in concept.

This is impossible in my opinion since :

  • In a doskey command such as doskey a b=ab, it takes "a" for an invalid option
  • The doskey command does not accept quotes around the macro name.

Here are some tests I have run :

image

As you can see, some special characters are accepted, but just not blanks.

Even without blanks in the macro name, doskey is an old DOS program and can only work in PowerShell with difficulty. It conflicts with the PSReadLine module which relies on the native console input functions. I tested this :

image2

As you can see, you need to do two additional actions :

  • Issue the command Remove-Module PSReadLine
  • Add to the doskey command the parameter /exename=powershell.exe

When both are done, the command is executed correctly and gives the right error.

My best advice is not to use doskey in PowerShell. Doskey is old and PowerShell is new, and they can only be used together with difficulty. I really don't think that doskey is so useful as to be irreplaceable.

Try to find another solution to your often-used commands. For example, store the commands in in executable files such as .ps1 or .cmd or .bat inside a folder that you would add to the PATH.

  • Why do I get ``` php_artisan : The term 'docker-compose exec apache php /home/medpets/WWW/laravel/artisan' 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, ve rify that the path is correct and try again. At line:1 char:1 + php_artisan list + ~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (docker-compose ...laravel/artisan:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException – Thomas Sep 28 '18 at 9:56
  • It's hard to understand from a comment. Could you please add a screenshot. – harrymc Sep 28 '18 at 10:05
  • imgur.com/a/XyXQCdx – Thomas Sep 28 '18 at 10:12
  • Thanks, please also include your doskey command. – harrymc Sep 28 '18 at 10:13
  • 1
    OK, I got it and modified my answer. – harrymc Sep 28 '18 at 10:30
2

There's no way to achieve this. Doskey macroname cannot have a space in it.

  • 1
    Is there a workaround? – Thomas Sep 28 '18 at 9:24
  • 3
    How about adding a "_" between or without added space, or something similar (like php_artisan or phpartisan)? – Aulis Ronkainen Sep 28 '18 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.