Php 在应用程序服务提供程序中找不到类架构-即使我添加了使用架构;
当我在线上传我的应用程序时,我遇到了一个错误,尽管这个错误没有出现在我的本地主机上 下面是我的appserviceprovider.php的样子 在你说之前,我改变了Php 在应用程序服务提供程序中找不到类架构-即使我添加了使用架构;,php,laravel,laravel-5.4,Php,Laravel,Laravel 5.4,当我在线上传我的应用程序时,我遇到了一个错误,尽管这个错误没有出现在我的本地主机上 下面是我的appserviceprovider.php的样子 在你说之前,我改变了 use Illuminate\Support\Facades\Schema; 到 我仍然有同样的问题 <?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Schema
use Illuminate\Support\Facades\Schema;
到
我仍然有同样的问题
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use DB;
use View;
use Request;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//Check for database connection
try {
DB::connection()->getPdo();
} catch (\Exception $e) {
if (Request::is('database/setup')) {
echo View::make('common/database/setup', array('error' => $e->getMessage()));
die();
}
else {
echo View::make('errors/database', array('error' => $e->getMessage()));
die();
}
}
Schema::defaultStringLength(191);
/*if (Schema::hasTable('categories')) {
$categories = DB::table('categories')->get();
view()->composer('frontend.layouts.include.header', function($view) use ($categories){
$view->with('categories',$categories);
});
}
if (Schema::hasTable('tags')) {
$tags = DB::table('tags')->get();
view()->composer('frontend.layouts.include.sidebar', function($view) use ($tags){
$view->with('tags',$tags);
});
}*/
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
我也有同样的问题。所以我只包括
使用照明\Support\Facades\Schema强>
位于AppServiceProvider类I的顶部,问题已解决
使用Laravel5.8,我尝试使用use-illible\Support\Facades\Schema
并在boot
方法中添加:Schema::defaultStringLength(191)代码>一切似乎都很好。附言:我也在5.4上。您是否尝试过清除缓存?这听起来可能有点愚蠢,但您是否安装了composer
?这是我们有时会忘记做的事情……你必须使用使用light\Support\Facades\Schema代码>我看到您包含了这个,所以我想问题是您使用的是启动方法,该方法在应用程序启动时运行一次,所以您需要重新启动服务器。另外,清除缓存和配置。希望它能工作。在cpanel中找到终端,然后运行命令composer dump-a
,然后php-artisan-cache:clear
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use DB;
use View;
use Request;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//Check for database connection
try {
DB::connection()->getPdo();
} catch (\Exception $e) {
if (Request::is('database/setup')) {
echo View::make('common/database/setup', array('error' => $e->getMessage()));
die();
}
else {
echo View::make('errors/database', array('error' => $e->getMessage()));
die();
}
}
Schema::defaultStringLength(191);
/*if (Schema::hasTable('categories')) {
$categories = DB::table('categories')->get();
view()->composer('frontend.layouts.include.header', function($view) use ($categories){
$view->with('categories',$categories);
});
}
if (Schema::hasTable('tags')) {
$tags = DB::table('tags')->get();
view()->composer('frontend.layouts.include.sidebar', function($view) use ($tags){
$view->with('tags',$tags);
});
}*/
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}