2017-12-18 183 views
0

我在工作Laravel 5.0。我的任務是關於讀取Excel/CSV文件等等。 但由於錯誤致命錯誤而無法繼續。Laravel 5.0讀取Excel文件時出錯

Fatal error: Class 'PHPExcel_Shared_Font' not found in /home/content/28/10055228/html/distribution/config/excel.php on line 182

composer.json

{ 
    "name": "laravel/laravel", 
    "description": "The Laravel Framework.", 
    "keywords": ["framework", "laravel"], 
    "license": "MIT", 
    "type": "project", 
    "require": { 
     "laravel/framework": "5.0.*", 
     "maatwebsite/excel": "~2.1.0", 
     "phpoffice/phpexcel": "1.8.1" 
    }, 
    "require-dev": { 
     "phpunit/phpunit": "~4.0", 
     "phpspec/phpspec": "~2.1" 
    }, 

/config/app.php(供應商和別名陣列)

'providers' => [ 

    /* 
    * Laravel Framework Service Providers... 
    */ 
    'Illuminate\Foundation\Providers\ArtisanServiceProvider', 
    'Illuminate\Auth\AuthServiceProvider', 
    'Illuminate\Bus\BusServiceProvider', 
    'Illuminate\Cache\CacheServiceProvider', 
    'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 
    'Illuminate\Routing\ControllerServiceProvider', 
    'Illuminate\Cookie\CookieServiceProvider', 
    'Illuminate\Database\DatabaseServiceProvider', 
    'Illuminate\Encryption\EncryptionServiceProvider', 
    'Illuminate\Filesystem\FilesystemServiceProvider', 
    'Illuminate\Foundation\Providers\FoundationServiceProvider', 
    'Illuminate\Hashing\HashServiceProvider', 
    'Illuminate\Mail\MailServiceProvider', 
    'Illuminate\Pagination\PaginationServiceProvider', 
    'Illuminate\Pipeline\PipelineServiceProvider', 
    'Illuminate\Queue\QueueServiceProvider', 
    'Illuminate\Redis\RedisServiceProvider', 
    'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 
    'Illuminate\Session\SessionServiceProvider', 
    'Illuminate\Translation\TranslationServiceProvider', 
    'Illuminate\Validation\ValidationServiceProvider', 
    'Illuminate\View\ViewServiceProvider', 

    /* 
    * Application Service Providers... 
    */ 
    'App\Providers\AppServiceProvider', 
    'App\Providers\BusServiceProvider', 
    'App\Providers\ConfigServiceProvider', 
    'App\Providers\EventServiceProvider', 
    'App\Providers\RouteServiceProvider', 
    'Maatwebsite\Excel\ExcelServiceProvider', 

], 

/* 
|-------------------------------------------------------------------------- 
| Class Aliases 
|-------------------------------------------------------------------------- 
| 
| This array of class aliases will be registered when this application 
| is started. However, feel free to register as many as you wish as 
| the aliases are "lazy" loaded so they don't hinder performance. 
| 
*/ 

'aliases' => [ 

    'App'  => 'Illuminate\Support\Facades\App', 
    'Artisan' => 'Illuminate\Support\Facades\Artisan', 
    'Auth'  => 'Illuminate\Support\Facades\Auth', 
    'Blade'  => 'Illuminate\Support\Facades\Blade', 
    'Bus'  => 'Illuminate\Support\Facades\Bus', 
    'Cache'  => 'Illuminate\Support\Facades\Cache', 
    'Config' => 'Illuminate\Support\Facades\Config', 
    'Cookie' => 'Illuminate\Support\Facades\Cookie', 
    'Crypt'  => 'Illuminate\Support\Facades\Crypt', 
    'DB'  => 'Illuminate\Support\Facades\DB', 
    'Eloquent' => 'Illuminate\Database\Eloquent\Model', 
    'Event'  => 'Illuminate\Support\Facades\Event', 
    'File'  => 'Illuminate\Support\Facades\File', 
    'Hash'  => 'Illuminate\Support\Facades\Hash', 
    'Input'  => 'Illuminate\Support\Facades\Input', 
    'Inspiring' => 'Illuminate\Foundation\Inspiring', 
    'Lang'  => 'Illuminate\Support\Facades\Lang', 
    'Log'  => 'Illuminate\Support\Facades\Log', 
    'Mail'  => 'Illuminate\Support\Facades\Mail', 
    'Password' => 'Illuminate\Support\Facades\Password', 
    'Queue'  => 'Illuminate\Support\Facades\Queue', 
    'Redirect' => 'Illuminate\Support\Facades\Redirect', 
    'Redis'  => 'Illuminate\Support\Facades\Redis', 
    'Request' => 'Illuminate\Support\Facades\Request', 
    'Response' => 'Illuminate\Support\Facades\Response', 
    'Route'  => 'Illuminate\Support\Facades\Route', 
    'Schema' => 'Illuminate\Support\Facades\Schema', 
    'Session' => 'Illuminate\Support\Facades\Session', 
    'Storage' => 'Illuminate\Support\Facades\Storage', 
    'URL'  => 'Illuminate\Support\Facades\URL', 
    'Validator' => 'Illuminate\Support\Facades\Validator', 
    'View'  => 'Illuminate\Support\Facades\View', 
    'Excel'  => 'Maatwebsite\Excel\Facades\Excel', 

], 

請指正。

感謝

+1

添加'「maatwebsite/excel」:「〜2.1.0」, 「phpoffice/phpexcel」:「1.8.1」'您是否運行過'composer install'?這是第一還是第二? – C2486

+0

實際上服務器是共享的,所以我無法做到這一點。並且我已經在localhost上實現了這個(工作正常)。在服務器上它出現錯誤。 –

+0

你沒有加載供應商文件夾中的所有相關文件,直到你運行'作曲家安裝' – C2486

回答

0

正如@ user2486已經指出的那樣,你有你的服務器上運行composer install。即使在共享主機上,也可以安裝作曲家,但這取決於主機。你可以問他們或看看How do I install Composer on a shared hosting?

如果這是不可能的,你應該得到另一個可能的託管包。否則將整個應用程序(包括vendor文件夾)推送到您的服務器。 提示:這不推薦,但更多的解決方法。

+0

感謝這麼多的信息 –