我的 laravel 5.6 项目在本地主机上打开,但在 php artisan serve cmd 上没有打开

My laravel 5.6 project is opening on localhost but not on php artisan serve cmd

我从朋友的 PC 上复制了 laravel 5.6 项目。 运行在他的 PC 上运行良好,但在我的 PC 上运行不佳。 当我在 cmd 中 运行 php artisan serve 命令时,它在 cmd 中给出了错误(附有屏幕截图)。cmd screenshot

它在 localhost/tailorMS 上打开:localhost screenshot

其他laravel版本7和8的项目在cmd上打开没有任何问题。 我的 AppServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use DB;
use Illuminate\Support\Facades\URL;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    public function boot()
    {
        if( (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) {
            URL::forceScheme('https');
        }
        //setting language
        if(isset($_COOKIE['language'])) {
            \App::setLocale($_COOKIE['language']);
        } else {
            \App::setLocale('en');
        }
        //get general setting value        
        $general_setting = DB::table('general_settings')->latest()->first();
        View::share('general_setting', $general_setting);
        config(['staff_access' => $general_setting->staff_access, 'date_format' => $general_setting->date_format, 'currency' => $general_setting->currency, 'currency_position' => $general_setting->currency_position]);
        
        $alert_product = DB::table('products')->where('is_active', true)->whereColumn('alert_quantity', '>', 'qty')->count();
        View::share('alert_product', $alert_product);
        Schema::defaultStringLength(191);
    }
}


更改条件检测是否为CLI调用,无需检查端口

if(strpos(php_sapi_name(), 'cli') === false && ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443)) {
    URL::forceScheme('https');
}