paranoid
paranoid

Reputation: 7105

Run php artisan command in out of laravel project

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?

Upvotes: 1

Views: 3126

Answers (2)

cherrysoft
cherrysoft

Reputation: 1195

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

Upvotes: 2

ArchBacon
ArchBacon

Reputation: 28

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

exec('php artisan migrate');

Upvotes: 0

Related Questions