2

This is just a general question, how does Laravel Artisan able to create proper .php file e.g. make:controller with the correct formatting and line breaks?

Is there a good PHP script which can help one develop similar php codes.

Thanks

Stanley Ngumo
  • 4,089
  • 8
  • 44
  • 64

2 Answers2

1

Ultimately, Artisan relies on Shell scripts included with Laravel. Which are written in the language of Shell and reside in files ending with the extension .sh. Here is a website that contains more explanation of what those are and how to develop them: https://www.shellscript.sh/ If this is ever unavailable simply searching "How to create a shell script" will get you the answer.

PHP can execute these scripts, for example, when you visit that PHP page in your browser, or you trigger it from the command line, assuming you have PHP installed on your server.

Artisan, is custom built to allow you to extend it with more commands, and there are tutorials available to show you how to do that, but it's a completely separate process from creating custom shell commands.

Spencer Hill
  • 1,043
  • 2
  • 15
  • 38
0

PHP files are just text files, you can easily create them with any language. Also in Laravel usually used so called stubs, templates for classes like migrations, controllers etc.

Just go and look how as Laravel does that under the hood.

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • Hi Alexey, I downvoted this but am willing to upvote it if you revise your answer. In my opinion you didn't answer his question. Because he didn't ask what PHP files are, and then your suggestions to 'just go and look' is vague. Thank you for your many contributions though! – Spencer Hill Aug 23 '21 at 02:17