简体   繁体   English

Laravel Artisan从错误的项目加载

[英]Laravel Artisan Loading from Wrong project

Sorry if this has been asked before but I can't seem to find the answer. 抱歉,以前是否有人问过我,但我似乎找不到答案。 I have a Laravel 5.5 application that lets users create their own project. 我有一个Laravel 5.5应用程序,可让用户创建自己的项目。 What this does is it executes a shell script that performs a git clone to a new directory 它的作用是执行一个执行git clone到新目录的shell脚本。

  • cd to the new git directory cd到新的git目录
  • update the .env db details to new directory (db_dirname) 将.env db详细信息更新到新目录(db_dirname)
  • run composer install 运行composer安装
  • php artisan key:generate PHP的工匠键:生成
  • php artisan migrate --seed PHP的工匠迁移-种子

The problem I'm having is that when I run this using... 我遇到的问题是,当我使用...运行此程序时

sh project1/public/createproject.sh subdir 

It runs as expected however when running this from PHP the php artisan commands are running against the current project rather than the project that is being dynamically created. 它可以按预期运行,但是从PHP运行时, php artisan命令针对当前项目而不是针对动态创建的项目运行。

 // Create the Git pull migration script
 $process = new Process('sh ./createproject.sh '.$this->url);
 $process->setTimeout(300);
 $process->run();

 // Executes after the command finishes
 if (!$process->isSuccessful()) {
     throw new ProcessFailedException($process3);
 }

 \Log::Debug($process->getOutput());

The shell script is below for reference. 下面是shell脚本供参考。

SUBDOMAIN="$1.domain.com"
git clone git@bitbucket.org:user/project.git
cd /home/cloudspr/$SUBDOMAIN
export COMPOSER_HOME="/opt/cpanel/composer/bin/composer"
composer install -d /home/user/$SUBDOMAIN
pwd
php artisan key:generate
php artisan migrate --seed --database=mysql
grep APP_KEY .env

Any help is much appreciated. 任何帮助深表感谢。

Seems like you have trouble selecting the right working directory. 似乎您在选择正确的工作目录时遇到了麻烦。

A couple if ideas come to mind: 如果有想法,请注意以下几点:

  1. Edit the bash script to point directly to the artisan file you are targeting: 编辑bash脚本以直接指向您要定位的工匠文件:

    php /home/user/project.../artisan key:generate php /home/user/project.../artisan键:生成

  2. Try changing the working directory before executing the script like this: 在执行脚本之前,请尝试更改工作目录,如下所示:

    $process = new Process('cd new/working/directory && sh ./createproject.sh '.$this->url); $ process = new Process('cd new / working / directory && sh ./createproject.sh'。$ this-> url);

  3. Use chdir 使用chdir

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

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