浏览代码

symlink检测

bianjunhui 2 周之前
父节点
当前提交
8dea1cc3d0
共有 1 个文件被更改,包括 16 次插入6 次删除
  1. 16 6
      packages/Webkul/BagistoApi/src/Console/Commands/InstallApiPlatformCommand.php

+ 16 - 6
packages/Webkul/BagistoApi/src/Console/Commands/InstallApiPlatformCommand.php

@@ -26,9 +26,9 @@ class InstallApiPlatformCommand extends Command
 
 
         try {
         try {
             $this->publishPackageAssets();
             $this->publishPackageAssets();
-            
+
             $this->registerServiceProvider();
             $this->registerServiceProvider();
-                     
+
             $this->linkApiPlatformAssets();
             $this->linkApiPlatformAssets();
 
 
             $this->updateComposerAutoload();
             $this->updateComposerAutoload();
@@ -37,10 +37,10 @@ class InstallApiPlatformCommand extends Command
 
 
             $this->registerApiPlatformProviders();
             $this->registerApiPlatformProviders();
 
 
-            $this->runDatabaseMigrations();           
+            $this->runDatabaseMigrations();
 
 
             $this->clearAndOptimizeCaches();
             $this->clearAndOptimizeCaches();
-            
+
             $this->generateApiKey();
             $this->generateApiKey();
 
 
             $this->publishConfiguration();
             $this->publishConfiguration();
@@ -49,7 +49,7 @@ class InstallApiPlatformCommand extends Command
 
 
             $this->info(__('bagistoapi::app.graphql.install.completed-success'));
             $this->info(__('bagistoapi::app.graphql.install.completed-success'));
             $this->newLine();
             $this->newLine();
-            
+
             $appUrl = config('app.url');
             $appUrl = config('app.url');
 
 
             $this->newLine();
             $this->newLine();
@@ -117,7 +117,7 @@ class InstallApiPlatformCommand extends Command
 
 
         $destination = config_path('api-platform.php');
         $destination = config_path('api-platform.php');
 
 
-        if ($this->files->exists(base_path('vendor/bagisto/bagisto-api/config/api-platform-vendor.php'))) { 
+        if ($this->files->exists(base_path('vendor/bagisto/bagisto-api/config/api-platform-vendor.php'))) {
             $source = $vendorSource;
             $source = $vendorSource;
         }
         }
 
 
@@ -303,6 +303,16 @@ class InstallApiPlatformCommand extends Command
         }
         }
 
 
         try {
         try {
+            if (!function_exists('symlink')) {
+                function symlink($target, $link) {
+                    // Windows系统使用不同的方法
+                    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+                        exec("mklink /J \"$link\" \"$target\"");
+                    } else {
+                        exec("ln -s \"$target\" \"$link\"");
+                    }
+                }
+            }
             symlink($vendorPath, $publicPath);
             symlink($vendorPath, $publicPath);
             $this->line(__('bagistoapi::app.graphql.install.asset-linked-success'));
             $this->line(__('bagistoapi::app.graphql.install.asset-linked-success'));
         } catch (\Exception $e) {
         } catch (\Exception $e) {