Это странно. Я просто добавил это в мой файл composer.json:
"maatwebsite/excel": "~2.1.0"
Еще когда я бегу composer install
эта библиотека не установлена:
composer show | grep excel
ничего не возвращает.
И поэтому каждый раз, когда я запускаю свой сценарий развертывания, я получаю эту ошибку:
> php artisan clear-compiled
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'PHPExcel_Shared_Font' not found in /Users/Shared/dev/php/toters-api/config/excel.php:182
Stack trace:
#0 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(60): require()
#1 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(38): Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\Foundation\Application), Object(Illuminate\Config\Repository))
#2 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap(Object(Illuminate\Foundation\Application))
#3 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)
#4 /Users/Shared/dev/php/toters-api/vendor/laravel/framew in /Users/Shared/dev/php/toters-api/config/excel.php on line 182
Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'PHPExcel_Shared_Font' not found in /Users/Shared/dev/php/toters-api/config/excel.php on line 182
Symfony\Component\Debug\Exception\FatalThrowableError: Class 'PHPExcel_Shared_Font' not found in /Users/Shared/dev/php/toters-api/config/excel.php on line 182
что является ожидаемой ошибкой, так как Composer игнорирует мой maatwebsite/excel
библиотека!
Я использую эти шаги, чтобы заставить его работать:
rm -rf vendor
rm composer.lock
composer install --no-scripts
но это явно уродливый и дорогой взлом (я добавил его в качестве предварительного хука в Envoyer автоматическое развертывание), и он работает каждый раз, но добавляет так много времени процессу автоматического развертывания.
Как я могу запустить команду Composer, которая заставляет это работать (но я также должен избегать composer update
команда, потому что я не хочу обновлять все мои библиотеки во время каждого развертывания, так как это приведет к непредсказуемым обновлениям моей базы кода)
Я просто заметил, что эта библиотека на нашей версии поддерживает более старую версию PHP — это может иметь к этому отношение?
Бег composer require maatwebsite/excel
возвращает следующее:
composer require maatwebsite/excel
Using version ^3.0 for maatwebsite/excel
./composer.json has been updated
> php artisan clear-compiled
The compiled class file has been removed.
> php artisan ide-helper:generate
A new helper file was written to _ide_helper.php
Unexpected no document on Illuminate\Database\Eloquent\Model
Wrote expected docblock to /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php
> php artisan ide-helper:models -N
Model information was written to _ide_helper_models.php
> php artisan optimize
Generating optimized class loader
The compiled class file has been removed.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove laravel/framework v5.3.31
- Conclusion: don't install laravel/framework v5.3.31
- maatwebsite/excel 3.0.1 requires illuminate/support ^5.5 -> satisfiable by illuminate/support[v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.2, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
- maatwebsite/excel 3.0.0 requires illuminate/support ^5.6 -> satisfiable by illuminate/support[v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.2, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
- don't install illuminate/support v5.5.0|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.16|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.17|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.2|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.28|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.33|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.34|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.35|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.36|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.37|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.39|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.5.40|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.6.0|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.6.1|don't install laravel/framework v5.3.31
- illuminate/support v5.6.10 conflicts with laravel/framework[v5.3.31].
- illuminate/support v5.6.11 conflicts with laravel/framework[v5.3.31].
- illuminate/support v5.6.12 conflicts with laravel/framework[v5.3.31].
- illuminate/support v5.6.13 conflicts with laravel/framework[v5.3.31].
- illuminate/support v5.6.14 conflicts with laravel/framework[v5.3.31].
- illuminate/support v5.6.15 conflicts with laravel/framework[v5.3.31].
- don't install illuminate/support v5.6.2|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.6.3|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.6.4|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.6.5|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.6.6|don't install laravel/framework v5.3.31
- don't install illuminate/support v5.6.7|don't install laravel/framework v5.3.31
- illuminate/support v5.6.8 conflicts with laravel/framework[v5.3.31].
- illuminate/support v5.6.9 conflicts with laravel/framework[v5.3.31].
- Installation request for laravel/framework (locked at v5.3.31, required as 5.3.*) -> satisfiable by laravel/framework[v5.3.31].
- Installation request for maatwebsite/excel ^3.0 -> satisfiable by maatwebsite/excel[3.0.0, 3.0.1].
Installation failed, reverting ./composer.json to its original content.
что ожидается, как последняя версия maatwebsite/excel
требуется laravel 5.5+,
но когда я бегу composer require maatwebsite/excel:2.1
Я все еще получаю ошибку:
./composer.json has been updated
> php artisan clear-compiled
The compiled class file has been removed.
> php artisan ide-helper:generate
A new helper file was written to _ide_helper.php
Tag Exists: @mixin \Eloquent in Illuminate\Database\Eloquent\Model
Tag Exists: @mixin \Illuminate\Database\Eloquent\Builder in Illuminate\Database\Eloquent\Model
Tag Exists: @mixin \Illuminate\Database\Query\Builder in Illuminate\Database\Eloquent\Model
> php artisan ide-helper:models -N
Model information was written to _ide_helper_models.php
> php artisan optimize
Generating optimized class loader
The compiled class file has been removed.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for maatwebsite/excel 2.1 -> satisfiable by maatwebsite/excel[v2.1.0].
- Conclusion: remove laravel/framework v5.3.31
- Conclusion: don't install laravel/framework v5.3.31
- maatwebsite/excel v2.1.0 requires illuminate/filesystem 5.0.*|5.1.*|5.2.* -> satisfiable by illuminate/filesystem[v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7].
- don't install illuminate/filesystem v5.0.0|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.0.22|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.0.25|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.0.26|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.0.28|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.0.33|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.0.4|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.1|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.13|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.16|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.2|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.20|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.22|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.25|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.28|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.30|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.31|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.41|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.6|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.1.8|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.0|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.19|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.21|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.24|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.25|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.26|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.27|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.28|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.31|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.32|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.37|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.43|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.45|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.6|don't install laravel/framework v5.3.31
- don't install illuminate/filesystem v5.2.7|don't install laravel/framework v5.3.31
- Installation request for laravel/framework (locked at v5.3.31, required as 5.3.*) -> satisfiable by laravel/framework[v5.3.31].
Installation failed, reverting ./composer.json to its original content.
что странно, так как он должен поддерживать Laravel 5.3 (мой Laravel):
но моя версия PHP 7.1.
composer install
не похоже npm install
, Я уверен, что если вы вручную добавите пакет, как вы это сделали, он игнорируется, так как composer.lock
уже там.
composer update
работал бы.composer require maatwebsite/excel
composer.lock
а затем работает composer install
Редактировать:
composer require maatwebsite/excel
будет пытаться установить последнюю версию этого пакета, но потому что вы используете laraval v5.3.31
вы должны установить maatwebsite/excel ~2.1.0
вместо. Версия 3 предназначена для laraval ^5.5
composer require "maatwebsite/excel:~2.1.0"
никогда, никогда, никогда не удаляйте composer.lock — если вы действительно не понимаете, что это значит, и готовы принять последствия.
Вы получаете установку, просто позвонив:
composer require maatwebsite/excel:~2.1
Который затем устанавливает версию 2.1.27.
Несколько слов о ваших сообщениях об ошибках. Там говорится, что maatwebsite / excel v2.1.0 требует подсветки / файловой системы 5.0.*|5.1.*|5.2.*
, Этот пакет заменен на laravel в той же версии (вы можете «прочитать» это в composer.lock).
Но вы используете laravel 5.3.31, поэтому существует конфликт версий. Но более новая версия от maatwebsite / excel совместима с большим количеством версийосвета / *.
В вашем случае вы можете попробовать composer require and that package name
то есть
composer require maatwebsite/excel