Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

johnw65's avatar

Disable PHP Artisan Command

Somewhat new to Laravel, and would like to disable PHP Artisan command, if possible, in a production environment.

What is the best method of accomplishing this? Also, can I automatically run 'php artisan serve' when the web server starts? Thank you in advance.

0 likes
5 replies
automica's avatar

@johnw65 considering you can only run artisan commands on commandline, what would be your reasoning to disable artisan? - particularly as you need to run artisan to cache clear etc.

As for running 'php artisan serve' you shouldn't run this on a production server or if you already have apache or nginx. Its meant just for local development purposes, if you don't have a local webserver.

johnw65's avatar

Automica,

So would the artisan command present any security vulnerabilities? Just want to make sure that someone doesn't accidentally run a command that would make any changes.

I really appreciate your responses, especially being relatively new to Laravel and Apache. So on my current development box with Apache web server, how would I start up the web site without 'php artisan serve' command on boot?

Also, I know this topic is just on disabling PHP artisan command, but how to you transfer all of your files from your development server to the production server? We don't currently have a production server, but I'm in the process of trying to document method to update the production server with the latest file from the development server.

Thanks again!

automica's avatar
automica
Best Answer
Level 54

@johnw65 depending on your hosting environment, you should already have apache or nginx installed and it should boot automatically (and be managed by your ISP).

'php artisan serve' command is rather like running php's local server

php -s localhost:8000

neither of these should be used for production.

As for 'someone doesn't accidentally run a command' - that'll be limited by whoever has commandline access. That should just be you or colleagues.

As for deploying files. You should be using a version control system such as git. As such you could also use git on your remote server and pulling the files directly from there.

if its a shared host, you may not have commandline or git access, so you'll need to get your files there someway else. You'd can do this using ssh, scp or rsync to copy files from your local to remote server. You could also use a sftp client to copy files from local to remote, by dragging up but that's a bit of a pain as you would usually replace all the files even though you might only change a few files.

For me, to get round the lack of git on one of my remotes, I use a service called deployhq.com

This allows you to register a repository and then the service can deploy from your repo via ssh to the server and it means you can deploy when you push up new file changes.

For other sites I'm using bitbucket pipelines, and doing something similar to deployhq where I run a specific deploy script to run tests, and then publish files to server by ssh.

johnw65's avatar

Automica, Thank you for the feedback. Due to my environment, I'm unable to use any outside service such as deployhq.com.

I do understand the concept of using ssh, scp or rsync to copy files from my development server to the production server. I will need to talk with my sys admin and figure out the best method.

Thank you again !

1 like

Please or to participate in this conversation.