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?
-
1You can execute Artisan commands programmatically but not sure you could use it for what you want to do: laravel.com/docs/5.6/…AntoineB– AntoineB2018-09-13 07:07:27 +00:00Commented Sep 13, 2018 at 7:07
-
I know this but I am out of laravel project.paranoid– paranoid2018-09-13 07:16:26 +00:00Commented Sep 13, 2018 at 7:16
-
What do you mean by "out of laravel project"?Nico Haase– Nico Haase2018-09-13 08:19:55 +00:00Commented 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.cherrysoft– cherrysoft2018-09-13 08:21:46 +00:00Commented Sep 13, 2018 at 8:21
Add a comment
|
2 Answers
Unfortunately artisan is baked into the Laravel Framework so your options are limited but you still have options.
- Use the Spatie laravel-migrate-fresh package (be sure to read before use)
- This would be suitable for a fresh install process
- Use a shell script for your build
- You can easily incorporate a shell script to run your migrations
- Roll your own installer using Symfony's console
- Vivek Kumar Bansal provides a good article on his Blog to do just this
- Create a standalone installer using Laravel
- This can contain your migrations and other commands (with input if you like)
- Nuno Maduros Laravel Zero could actually be perfect for you!
- It has migrations built in
Comments
You can use php's exec() function.
http://php.net/manual/en/function.exec.php
exec('php artisan migrate');
1 Comment
Dave Carruthers
How is this any different to running
system("php artisan migrate") which the OP is trying to avoid?.