简体   繁体   English

在laravel项目中运行php artisan命令

[英]Run php artisan command in out of laravel project

I am writing an installer for laravel project. 我正在编写laravel项目的安装程序。
but for some reason, I don't run this installer from laravel project. 但是由于某种原因,我没有从laravel项目运行此安装程序。
I use PHP code. 我使用PHP代码。 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. 我想在安装程序上使用php artisan migrate ,我知道我可以使用此命令system("php artisan migrate")但我不想在安装程序上使用system functions Is there any way to artisan command on PHP out of laravel? 有没有办法从laravel中在PHP上使用artisan命令?

Unfortunately artisan is baked into the Laravel Framework so your options are limited but you still have options. 不幸的是,工匠已经融入Laravel框架,因此您的选择有限,但您仍然可以选择。

  1. Use the Spatie laravel-migrate-fresh package (be sure to read before use) 使用Spatie laravel-migrate-fresh软件包(使用前请务必阅读)
    • This would be suitable for a fresh install process 这将适合全新安装过程
  2. Use a shell script for your build 使用Shell脚本进行构建
    • You can easily incorporate a shell script to run your migrations 您可以轻松地合并一个shell脚本来运行您的迁移
  3. Roll your own installer using Symfony's console 使用Symfony的控制台滚动自己的安装程序
  4. Create a standalone installer using Laravel 使用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! Nuno Maduros Laravel Zero实际上可能是您的完美选择!
    • It has migrations built in 它内置了迁移

You can use php's exec() function. 您可以使用php的exec()函数。
http://php.net/manual/en/function.exec.php http://php.net/manual/en/function.exec.php

exec('php artisan migrate');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM