【发布时间】:2018-02-24 19:39:11
【问题描述】:
问题:
在 localhost 上运行 Laravel 项目没有任何问题,但尝试在 Heroku 上部署它是不成功的。
错误:
FatalThrowableError
Class 'Predis\Client' not found
composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.1.3",
"darkaonline/l5-swagger": "5.6.*",
"fideloper/proxy": "~4.0",
"laravel/framework": "5.6.*",
"laravel/passport": "^5.0",
"laravel/tinker": "~1.0",
"predis/predis": "^1.1",
"spatie/laravel-permission": "^2.9"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"nunomaduro/collision": "~1.1",
"phpunit/phpunit": "~7.0",
"reliese/laravel": "^0.0.13",
"symfony/thanks": "^1.0",
"xethron/migrations-generator": "^2.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Heroku CLI(登录到 Heroku bash tty):
这里我尝试安装 composer 依赖并更新它们
~ $ composer install --dev && composer update
You are using the deprecated option "dev". Dev packages are installed by default now.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Package operations: 41 installs, 0 updates, 0 removals
- Installing symfony/thanks (v1.0.5): Downloading (100%)
- Installing doctrine/collections (v1.5.0): Downloading (100%)
- Installing doctrine/cache (v1.7.1): Downloading (100%)
- Installing doctrine/common (v2.8.1): Downloading (100%)
- Installing fzaninotto/faker (v1.7.1): Downloading (100%)
- Installing hamcrest/hamcrest-php (v2.0.0): Downloading (100%)
- Installing mockery/mockery (1.0): Downloading (100%)
- Installing filp/whoops (2.1.14): Downloading (100%)
- Installing nunomaduro/collision (v1.1.22): Downloading (100%)
- Installing webmozart/assert (1.3.0): Downloading (100%)
- Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%)
- Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)
- Installing phpdocumentor/reflection-docblock (4.3.0): Downloading (100%)
- Installing phpunit/php-token-stream (3.0.0): Downloading (100%)
- Installing sebastian/version (2.0.1): Downloading (100%)
- Installing sebastian/resource-operations (1.0.0): Downloading (100%)
- Installing sebastian/recursion-context (3.0.0): Downloading (100%)
- Installing sebastian/object-reflector (1.1.1): Downloading (100%)
- Installing sebastian/object-enumerator (3.0.3): Downloading (100%)
- Installing sebastian/global-state (2.0.0): Downloading (100%)
- Installing sebastian/exporter (3.1.0): Downloading (100%)
- Installing sebastian/environment (3.1.0): Downloading (100%)
- Installing sebastian/diff (3.0.0): Downloading (100%)
- Installing sebastian/comparator (2.1.3): Downloading (100%)
- Installing phpunit/php-text-template (1.2.1): Downloading (100%)
- Installing doctrine/instantiator (1.1.0): Downloading (100%)
- Installing phpunit/phpunit-mock-objects (6.0.1): Downloading (100%)
- Installing phpunit/php-timer (2.0.0): Downloading (100%)
- Installing phpunit/php-file-iterator (1.4.5): Downloading (100%)
- Installing theseer/tokenizer (1.1.0): Downloading (100%)
- Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%)
- Installing phpunit/php-code-coverage (6.0.1): Downloading (100%)
- Installing phpspec/prophecy (1.7.4): Downloading (100%)
- Installing phar-io/version (1.0.1): Downloading (100%)
- Installing phar-io/manifest (1.0.1): Downloading (100%)
- Installing myclabs/deep-copy (1.7.0): Downloading (100%)
- Installing phpunit/phpunit (7.0.1): Downloading (100%)
- Installing doctrine/dbal (v2.6.3): Downloading (100%)
- Installing reliese/laravel (v0.0.13): Downloading (100%)
- Installing xethron/laravel-4-generators (3.1.1): Downloading (100%)
- Installing xethron/migrations-generator (v2.0.2): Downloading (100%)
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.6.0)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0)
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: darkaonline/l5-swagger
Discovered Package: fideloper/proxy
Discovered Package: laravel/passport
Discovered Package: laravel/tinker
Discovered Package: nunomaduro/collision
Discovered Package: spatie/laravel-permission
Discovered Package: xethron/migrations-generator
Package manifest generated successfully.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 5 updates, 0 removals
- Updating symfony/thanks (v1.0.5 => v1.0.6): Downloading (100%)
- Updating laravel/framework (v5.6.3 => v5.6.5): Downloading (100%)
- Updating darkaonline/l5-swagger (5.6.1 => 5.6.2): Downloading (100%)
- Updating phpseclib/phpseclib (2.0.9 => 2.0.10): Downloading (100%)
- Updating phpspec/prophecy (1.7.4 => 1.7.5): Downloading (100%)
- Installing predis/predis (v1.1.1): Downloading (100%)
predis/predis suggests installing ext-phpiredis (Allows faster serialization and deserialization of the Redis protocol) Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: darkaonline/l5-swagger
Discovered Package: fideloper/proxy
Discovered Package: laravel/passport
Discovered Package: laravel/tinker
Discovered Package: nunomaduro/collision
Discovered Package: spatie/laravel-permission
Discovered Package: xethron/migrations-generator
Package manifest generated successfully.
What about running composer thanks now?
This will spread some ???? by sending a ★ to the GitHub repositories of your fellow package maintainers.
~ $ ls vendor/|grep red
predis
如您所见,redis文件夹加载成功。但是类 'Predis\Client' not found 仍在发生!
关闭 bash 并重新登录 Heroku 后,redis 文件夹神秘地消失了:'(
~ $ exit
C:\Users\XTreme.ws
λ heroku run bash -a dfs-server
Running bash on dfs-server... up, run.7714 (Free)
~ $ ls vendor/|grep red
~ $
在 Heroku Dashboard 中,项目成功部署,没有任何错误。
那我做错了什么?在 Internet 上进行了谷歌搜索,但没有任何解决该问题的方法。
【问题讨论】: