1

I am writing an installer for laravel project.
but for some reason, I don't run this installer from laravel project.
I use PHP code. I want to use php artisan migrate on my installer and I know that I can use this command system("php artisan migrate") but I don't want to use system functions on my installer. Is there any way to artisan command on PHP out of laravel?

4
  • 1
    You can execute Artisan commands programmatically but not sure you could use it for what you want to do: laravel.com/docs/5.6/… Commented Sep 13, 2018 at 7:07
  • I know this but I am out of laravel project. Commented Sep 13, 2018 at 7:16
  • What do you mean by "out of laravel project"? Commented Sep 13, 2018 at 8:19
  • I believe they mean to say their installer is not using Laravel and they also do not wish to use system calls from PHP as part of the process. Commented Sep 13, 2018 at 8:21

2 Answers 2

2

Unfortunately artisan is baked into the Laravel Framework so your options are limited but you still have options.

  1. Use the Spatie laravel-migrate-fresh package (be sure to read before use)
    • This would be suitable for a fresh install process
  2. Use a shell script for your build
    • You can easily incorporate a shell script to run your migrations
  3. Roll your own installer using Symfony's console
    • Vivek Kumar Bansal provides a good article on his Blog to do just this
  4. Create a standalone installer using Laravel
    • This can contain your migrations and other commands (with input if you like)
  5. Nuno Maduros Laravel Zero could actually be perfect for you!
    • It has migrations built in
Sign up to request clarification or add additional context in comments.

Comments

0

You can use php's exec() function.
http://php.net/manual/en/function.exec.php

exec('php artisan migrate');

1 Comment

How is this any different to running system("php artisan migrate") which the OP is trying to avoid?.

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.