我的laravel 5.6项目是在localhost上打开的,但不是在php artisan serve cmd上



我从朋友的电脑上复制了laravel 5.6项目。它在他的电脑上运行得很好,但在我的电脑上运行不好。当我在cmd中运行php artisan serve命令时,它会给我cmd中的错误(附屏幕截图(。cmd屏幕截图

它在localhost/tailorMS上打开:localhost屏幕截图

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

<?php
namespace AppProviders;
use IlluminateSupportServiceProvider;
use IlluminateSupportFacadesSchema;
use IlluminateSupportFacadesView;
use DB;
use IlluminateSupportFacadesURL;
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');
}

最新更新