2

Now I have a Laravel project, and I want to deploy to the server. My application needs to run some laravel command line just one time to deploy.

Ex: php artisan key:generate, or php artisan storage:link.

How can I autorun those command-line when deploying the application to the server?

P/s: Of course I can run by typing, but I don't want. Any best solution to run all of them just by one manipulation?

9
  • laravel.com/docs/5.0/artisan#scheduling-artisan-commands Commented Aug 1, 2018 at 7:20
  • Could try Envoy. "Of course I can run by typing, but I don't want." That's two lines you need to type! Commented Aug 1, 2018 at 7:20
  • 1
    You can use composer post-install scripts. Commented Aug 1, 2018 at 7:22
  • @kerbholz I know I can type, but I don't want. I just want to find a solution to run all of them one time. Commented Aug 1, 2018 at 7:23
  • @jrswgtr Any example, I'm not good at composer Commented Aug 1, 2018 at 7:25

1 Answer 1

4

if you're using composer there are commands you can provide in scripts node. See https://getcomposer.org/doc/articles/scripts.md for more details. then you can also define your own script. i.e compile:

{
  ...
  "scripts": {
    "compile": [
      "mkdir logs",
      "echo 'hello world'",
      "./deploy/heroku/run.sh"
    ],
    "post-install-cmd": [
        "echo composer finished installing, do your commands here"
    ],
    "post-update-cmd": [
        "echo composer finished updating, do your commands here"
    ]
  }
}

and run with composer run-script compile

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.