我将一个 laravel 项目上传到 plesk,但我遇到了 laravel/sanctum 的问题

问题描述 投票:0回答:2

我需要一些帮助...

我已将一家公司提供的 Laravel 项目上传到我的 plesk 服务器。

但是,在显示网页时出现以下错误: 糟糕,好像出了什么问题。

检查 Laravel.log 时,我收到以下消息:

production.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Laravel\Sanctum\Sanctum' not found in /var/www/vhosts/sweet-tharp.51-254-103-53.plesk.page/httpdocs/config/sanctum.php:21
Stack trace:
#0 /var/www/vhosts/sweet-tharp.51-254-103-53.plesk.page/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(71): require()
#1 /var/www/vhosts/sweet-tharp.51-254-103-53.plesk.page/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(39): Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\Foundation\Application), Object(Illuminate\Config\Repository))
#2 /var/www/vhosts/sweet-tharp.51-254-103-53.plesk.page/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(208): Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap(Object(Illuminate\Foundation\Application))
#3 /var/www/vhosts/sweet-tharp.51-254-103-53.plesk.page/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\Foundation\Application->bootstrapWith(Array)
#4 /var/www/vhosts/sweet-tharp.51-254-103-53.plesk.page/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(146): Illuminate\Foundation\Http\Kernel->bootstrap()
#5 /var/www/vhosts/sweet-tharp.51-254-103-53.plesk.page/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#6 /var/www/vhosts/sweet-tharp.51-254-103-53.plesk.page/httpdocs/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#7 {main}  

经过调查,我发现你不应该安装 laravel/sanctum。

但是,安装时出现以下错误:

# composer require laravel/sanctum
Execution /usr/bin/php has failed with exit code 2, stdout: , stderr: Using version ^2.15 for laravel/sanctum
./composer.json has been updated
Running composer update laravel/sanctum
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires laravel/sanctum ^2.15 -> satisfiable by laravel/sanctum[v2.15.0, v2.15.1].
    - laravel/sanctum[v2.15.0, ..., v2.15.1] require illuminate/console ^6.9|^7.0|^8.0|^9.0 -> found illuminate/console[v6.10.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.15] but these were not loaded, likely because it conflicts with another require.

You can also try re-running composer require with an explicit version constraint, e.g. "composer require laravel/sanctum:*" to figure out if any version is installable, or "composer require laravel/sanctum:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

我已经检查过了,应该更新 laravel/framework 并让我安装 sainttum,但是这样做时出现以下错误:

# composer update laravel/framework
Execution /usr/bin/php has failed with exit code 1, stdout: Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
    You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.
    
In sanctum.php line 21:
                                             
  Class 'Laravel\Sanctum\Sanctum' not found  
                                             

, stderr: Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package chumper/zipper is abandoned, you should avoid using it. No replacement was suggested.
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package laravelcollective/html is abandoned, you should avoid using it. Use spatie/laravel-html instead.
Package maddhatter/laravel-fullcalendar is abandoned, you should avoid using it. No replacement was suggested.
Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Class Illuminate\Support\Traits\EnumeratesValues located in ./vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Arr located in ./vendor/laravel/framework/src/Illuminate/Collections/Arr.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Enumerable located in ./vendor/laravel/framework/src/Illuminate/Collections/Enumerable.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\HigherOrderCollectionProxy located in ./vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\MultipleItemsFoundException located in ./vendor/laravel/framework/src/Illuminate/Collections/MultipleItemsFoundException.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\LazyCollection located in ./vendor/laravel/framework/src/Illuminate/Collections/LazyCollection.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\ItemNotFoundException located in ./vendor/laravel/framework/src/Illuminate/Collections/ItemNotFoundException.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Collection located in ./vendor/laravel/framework/src/Illuminate/Collections/Collection.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Traits\Macroable located in ./vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Traits\Conditionable located in ./vendor/laravel/framework/src/Illuminate/Conditionable/Traits/Conditionable.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\HigherOrderWhenProxy located in ./vendor/laravel/framework/src/Illuminate/Conditionable/HigherOrderWhenProxy.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Mail\Feder located in ./app/Http/Mail/Feder.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Mail\Contacto located in ./app/Http/Mail/Contact.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Mail\Feder located in ./app/Http/Mail/Feder-antifraude.php does not comply with psr-4 autoloading standard. Skipping.
38 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Script php artisan optimize handling the post-update-cmd event returned with error code 1

但是,它没有,因为它没有安装 laravel/sanctum。

谁能帮我解决这个错误吗?

证据和证据都在解释里

laravel plesk laravel-sanctum
2个回答
0
投票

您的作曲家文件中存在冲突。您尝试安装的 sainttum 版本与控制台库不兼容。您应该从 Composer 文件中删除 sainttum ,然后运行以下命令来查看哪个版本与您安装的其他库兼容:

composer require laravel/sanctum:*

0
投票

我尝试删除 laravel/sanctum 但它也不起作用,它说:

# composer remove laravel/sanctum
Execution /usr/bin/php has failed with exit code 1, stdout: Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
    You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.
    
In sanctum.php line 21:
                                             
  Class 'Laravel\Sanctum\Sanctum' not found  
                                             

, stderr: laravel/sanctum is not required in your composer.json and has not been removed
./composer.json has been updated
Running composer update laravel/sanctum
Loading composer repositories with package information
Package "laravel/sanctum" listed for update is not locked.
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package chumper/zipper is abandoned, you should avoid using it. No replacement was suggested.
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package laravelcollective/html is abandoned, you should avoid using it. Use spatie/laravel-html instead.
Package maddhatter/laravel-fullcalendar is abandoned, you should avoid using it. No replacement was suggested.
Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Class Illuminate\Support\Traits\EnumeratesValues located in ./vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Arr located in ./vendor/laravel/framework/src/Illuminate/Collections/Arr.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Enumerable located in ./vendor/laravel/framework/src/Illuminate/Collections/Enumerable.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\HigherOrderCollectionProxy located in ./vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\MultipleItemsFoundException located in ./vendor/laravel/framework/src/Illuminate/Collections/MultipleItemsFoundException.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\LazyCollection located in ./vendor/laravel/framework/src/Illuminate/Collections/LazyCollection.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\ItemNotFoundException located in ./vendor/laravel/framework/src/Illuminate/Collections/ItemNotFoundException.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Collection located in ./vendor/laravel/framework/src/Illuminate/Collections/Collection.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Traits\Macroable located in ./vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\Traits\Conditionable located in ./vendor/laravel/framework/src/Illuminate/Conditionable/Traits/Conditionable.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Support\HigherOrderWhenProxy located in ./vendor/laravel/framework/src/Illuminate/Conditionable/HigherOrderWhenProxy.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Mail\Feder located in ./app/Http/Mail/Feder.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Mail\Contacto located in ./app/Http/Mail/Contact.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Mail\Feder located in ./app/Http/Mail/Feder-antifraude.php does not comply with psr-4 autoloading standard. Skipping.
38 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Script php artisan optimize handling the post-update-cmd event returned with error code 1

无论如何,为了它的价值,我也尝试过 require laravel/sanctum:* 但它也给了我错误。

# composer require laravel/sanctum:*
Execution /usr/bin/php has failed with exit code 2, stdout: , stderr: Info from https://repo.packagist.org: #StandWithUkraine
./composer.json has been updated
Running composer update laravel/sanctum
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/sanctum[v0.1.0, ..., v0.2.1, v1.0.0] require illuminate/contracts ^6.0|^7.0 -> found illuminate/contracts[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6] but these were not loaded, likely because it conflicts with another require.
    - laravel/sanctum[v1.0.1, v2.0.0, ..., v2.4.2] require illuminate/contracts ^6.9|^7.0 -> found illuminate/contracts[v6.10.0, ..., v6.20.44, v7.0.0, ..., v7.30.6] but these were not loaded, likely because it conflicts with another require.
    - laravel/sanctum[v2.5.0, ..., v2.13.0] require illuminate/contracts ^6.9|^7.0|^8.0 -> found illuminate/contracts[v6.10.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - laravel/sanctum[v2.14.0, ..., v2.14.2] require illuminate/contracts ^6.9|^7.0|^8.0|^9.0 -> found illuminate/contracts[v6.10.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.15] but these were not loaded, likely because it conflicts with another require.
    - laravel/sanctum[v2.15.0, ..., v2.15.1] require illuminate/console ^6.9|^7.0|^8.0|^9.0 -> found illuminate/console[v6.10.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.15] but these were not loaded, likely because it conflicts with another require.
    - laravel/sanctum[v3.0.0, ..., v3.2.5] require php ^8.0.2 -> your php version (7.3.31) does not satisfy that requirement.
    - Root composer.json requires laravel/sanctum * -> satisfiable by laravel/sanctum[v0.1.0, v0.2.0, v0.2.1, v1.0.0, v1.0.1, v2.0.0, ..., v2.15.1, v3.0.0, ..., v3.2.5].


Installation failed, reverting ./composer.json and ./composer.lock to their original content.
© www.soinside.com 2019 - 2024. All rights reserved.