Laravel 5.0 getting error while reading excel file

时间:2017-12-18 07:16:11

标签: laravel laravel-5

I am in working Laravel 5.0. My task is about read Excel/CSV files and all that. But can't able to continue due to following error Fatal error.

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 and aliases array)

'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',

],

Please correct me.

Thanks

2 个答案:

答案 0 :(得分:0)

正如@ user2486已经指出的那样,您必须在服务器上运行composer install。即使在共享主机上也可以安装composer,但这取决于主机。您可以询问他们或查看How do I install Composer on a shared hosting?

如果不可能,您应该获得另一个托管包。否则将整个应用程序(包括vendor文件夹)推送到您的服务器。 提示:不建议这样做,但更多是解决方法。

答案 1 :(得分:0)

您可以使用以下命令

composer require maatwebsite/excel
OR
composer require "maatwebsite/excel":"~2.1.0"