如何在thinkphp6中使用Eloquent ORM

浏览:1762 发布日期:2021/04/14 分类:求助交流 关键字: EloquentORM thinkphp6
RT
我記得以前在thinkphp5中使用composer引用即可
但現在嘗試在thinkphp6中通過composer引用後出現錯誤vagrant@vagrant:/www/wwwroot/thinkauth$ composer require illuminate/database
Using version ^8.37 for illuminate/database
./composer.json has been updated
Running composer update illuminate/database
Loading composer repositories with package information
Updating dependencies
Lock file operations: 18 installs, 0 updates, 0 removals
  - Locking doctrine/inflector (2.0.3)
  - Locking illuminate/collections (v8.37.0)
  - Locking illuminate/container (v8.37.0)
  - Locking illuminate/contracts (v8.37.0)
  - Locking illuminate/database (v8.37.0)
  - Locking illuminate/macroable (v8.37.0)
  - Locking illuminate/support (v8.37.0)
  - Locking nesbot/carbon (2.46.0)
  - Locking symfony/console (v5.2.6)
  - Locking symfony/polyfill-ctype (v1.22.1)
  - Locking symfony/polyfill-intl-grapheme (v1.22.1)
  - Locking symfony/polyfill-intl-normalizer (v1.22.1)
  - Locking symfony/polyfill-php73 (v1.22.1)
  - Locking symfony/service-contracts (v2.2.0)
  - Locking symfony/string (v5.2.6)
  - Locking symfony/translation (v5.2.6)
  - Locking symfony/translation-contracts (v2.3.0)
  - Locking voku/portable-ascii (1.5.6)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 18 installs, 0 updates, 0 removals
  - Downloading illuminate/macroable (v8.37.0)
  - Downloading illuminate/contracts (v8.37.0)
  - Downloading illuminate/collections (v8.37.0)
  - Downloading illuminate/support (v8.37.0)
  - Downloading illuminate/container (v8.37.0)
  - Downloading illuminate/database (v8.37.0)
  - Installing symfony/polyfill-intl-normalizer (v1.22.1): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.22.1): Extracting archive
  - Installing symfony/polyfill-ctype (v1.22.1): Extracting archive
  - Installing symfony/string (v5.2.6): Extracting archive
  - Installing symfony/service-contracts (v2.2.0): Extracting archive
  - Installing symfony/polyfill-php73 (v1.22.1): Extracting archive
  - Installing symfony/console (v5.2.6): Extracting archive
  - Installing voku/portable-ascii (1.5.6): Extracting archive
  - Installing symfony/translation-contracts (v2.3.0): Extracting archive
  - Installing symfony/translation (v5.2.6): Extracting archive
  - Installing nesbot/carbon (2.46.0): Extracting archive
  - Installing illuminate/macroable (v8.37.0): Extracting archive
  - Installing illuminate/contracts (v8.37.0): Extracting archive
  - Installing illuminate/collections (v8.37.0): Extracting archive
  - Installing doctrine/inflector (2.0.3): Extracting archive
  - Installing illuminate/support (v8.37.0): Extracting archive
  - Installing illuminate/container (v8.37.0): Extracting archive
  - Installing illuminate/database (v8.37.0): Extracting archive
18 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
> @php think service:discover
PHP Fatal error:  Uncaught Error: Class 'PhpOption\Option' not found in /www/wwwroot/thinkauth/vendor/illuminate/support/Env.php:76
Stack trace:
#0 /www/wwwroot/thinkauth/vendor/illuminate/support/helpers.php(132): Illuminate\Support\Env::get()
#1 /www/wwwroot/thinkauth/config/app.php(8): env()
#2 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Config.php(92): include('/www/wwwroot/th...')
#3 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Config.php(73): think\Config->parse()
#4 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/App.php(511): think\Config->load()
#5 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/App.php(420): think\App->load()
#6 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Console.php(110): think\App->initialize()
#7 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Console.php(94): think\Console->initialize()
#8 [internal function]: think\Console->__construct()
#9 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Container.php(394): R in /www/wwwroot/thinkauth/vendor/illuminate/support/Env.php on line 76
Script @php think service:discover handling the post-autoload-dump event returned with error code 255

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
然後引用了phpoption/phpoption後出現了新的錯誤vagrant@vagrant:/www/wwwroot/thinkauth$ composer require phpoption/phpoption
Using version ^1.7 for phpoption/phpoption
./composer.json has been updated
Running composer update phpoption/phpoption
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking phpoption/phpoption (1.7.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 18 removals
  - Removing voku/portable-ascii (1.5.6)
  - Removing symfony/translation-contracts (v2.3.0)
  - Removing symfony/translation (v5.2.6)
  - Removing symfony/string (v5.2.6)
  - Removing symfony/service-contracts (v2.2.0)
  - Removing symfony/polyfill-php73 (v1.22.1)
  - Removing symfony/polyfill-intl-normalizer (v1.22.1)
  - Removing symfony/polyfill-intl-grapheme (v1.22.1)
  - Removing symfony/polyfill-ctype (v1.22.1)
  - Removing symfony/console (v5.2.6)
  - Removing nesbot/carbon (2.46.0)
  - Removing illuminate/support (v8.37.0)
  - Removing illuminate/macroable (v8.37.0)
  - Removing illuminate/database (v8.37.0)
  - Removing illuminate/contracts (v8.37.0)
  - Removing illuminate/container (v8.37.0)
  - Removing illuminate/collections (v8.37.0)
  - Removing doctrine/inflector (2.0.3)
  - Installing phpoption/phpoption (1.7.5): Extracting archive
Generating autoload files
> @php think service:discover
Succeed!
> @php think vendor:publish
File /www/wwwroot/thinkauth/config/trace.php exist!
Succeed!
10 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
vagrant@vagrant:/www/wwwroot/thinkauth$ composer require illuminate/database
Using version ^8.37 for illuminate/database
./composer.json has been updated
Running composer update illuminate/database
Loading composer repositories with package information
Updating dependencies
Lock file operations: 18 installs, 0 updates, 0 removals
  - Locking doctrine/inflector (2.0.3)
  - Locking illuminate/collections (v8.37.0)
  - Locking illuminate/container (v8.37.0)
  - Locking illuminate/contracts (v8.37.0)
  - Locking illuminate/database (v8.37.0)
  - Locking illuminate/macroable (v8.37.0)
  - Locking illuminate/support (v8.37.0)
  - Locking nesbot/carbon (2.46.0)
  - Locking symfony/console (v5.2.6)
  - Locking symfony/polyfill-ctype (v1.22.1)
  - Locking symfony/polyfill-intl-grapheme (v1.22.1)
  - Locking symfony/polyfill-intl-normalizer (v1.22.1)
  - Locking symfony/polyfill-php73 (v1.22.1)
  - Locking symfony/service-contracts (v2.2.0)
  - Locking symfony/string (v5.2.6)
  - Locking symfony/translation (v5.2.6)
  - Locking symfony/translation-contracts (v2.3.0)
  - Locking voku/portable-ascii (1.5.6)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 18 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-intl-normalizer (v1.22.1): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.22.1): Extracting archive
  - Installing symfony/polyfill-ctype (v1.22.1): Extracting archive
  - Installing symfony/string (v5.2.6): Extracting archive
  - Installing symfony/service-contracts (v2.2.0): Extracting archive
  - Installing symfony/polyfill-php73 (v1.22.1): Extracting archive
  - Installing symfony/console (v5.2.6): Extracting archive
  - Installing voku/portable-ascii (1.5.6): Extracting archive
  - Installing symfony/translation-contracts (v2.3.0): Extracting archive
  - Installing symfony/translation (v5.2.6): Extracting archive
  - Installing nesbot/carbon (2.46.0): Extracting archive
  - Installing illuminate/macroable (v8.37.0): Extracting archive
  - Installing illuminate/contracts (v8.37.0): Extracting archive
  - Installing illuminate/collections (v8.37.0): Extracting archive
  - Installing doctrine/inflector (2.0.3): Extracting archive
  - Installing illuminate/support (v8.37.0): Extracting archive
  - Installing illuminate/container (v8.37.0): Extracting archive
  - Installing illuminate/database (v8.37.0): Extracting archive
18 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
> @php think service:discover
PHP Fatal error:  Uncaught Error: Class 'Dotenv\Repository\RepositoryBuilder' not found in /www/wwwroot/thinkauth/vendor/illuminate/support/Env.php:55
Stack trace:
#0 /www/wwwroot/thinkauth/vendor/illuminate/support/Env.php(76): Illuminate\Support\Env::getRepository()
#1 /www/wwwroot/thinkauth/vendor/illuminate/support/helpers.php(132): Illuminate\Support\Env::get()
#2 /www/wwwroot/thinkauth/config/app.php(8): env()
#3 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Config.php(92): include('/www/wwwroot/th...')
#4 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Config.php(73): think\Config->parse()
#5 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/App.php(511): think\Config->load()
#6 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/App.php(420): think\App->load()
#7 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Console.php(110): think\App->initialize()
#8 /www/wwwroot/thinkauth/vendor/topthink/framework/src/think/Console.php(94): think\Console->initialize()
#9 [internal in /www/wwwroot/thinkauth/vendor/illuminate/support/Env.php on line 55
Script @php think service:discover handling the post-autoload-dump event returned with error code 255

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
最佳答案
评论( 相关
后面还有条评论,点击查看>>