ThinPHP 8最新版框架学习--持续更新中

79524795 / 2024-06-07 / 原文

1.下载安装TP8

必须用composer安装,

composer create-project topthink/think tp

要注意的是你的PHP版本必须>=8,才能正常安装,否则,你会下载成TP6的!

2.开启多应用

官网教程https://doc.thinkphp.cn/v8_0/multi_app_model.html

但是我安装的时候有报错 报错内容如下:

PHP Deprecated:  Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112

Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112

解决方案

第一步更新composer composer self-update

很不幸我更新composer时候又报错

[root@VM-16-6-centos newtp.79524795.vip]# composer self-update
PHP Deprecated:  Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112

Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112
[root@VM-16-6-centos config]# composer self-update
PHP Fatal error:  Uncaught Error: Call to undefined function Composer\XdebugHandler\putenv() in phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/Process.php:98
Stack trace:
#0 phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/Status.php(59): Composer\XdebugHandler\Process::setEnv()
#1 phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/XdebugHandler.php(101): Composer\XdebugHandler\Status->__construct()
#2 phar:///usr/bin/composer/bin/composer(28): Composer\XdebugHandler\XdebugHandler->__construct()
#3 /usr/bin/composer(29): require('...')
#4 {main}
  thrown in phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/Process.php on line 98

Fatal error: Uncaught Error: Call to undefined function Composer\XdebugHandler\putenv() in phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/Process.php:98
Stack trace:
#0 phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/Status.php(59): Composer\XdebugHandler\Process::setEnv()
#1 phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/XdebugHandler.php(101): Composer\XdebugHandler\Status->__construct()
#2 phar:///usr/bin/composer/bin/composer(28): Composer\XdebugHandler\XdebugHandler->__construct()
#3 /usr/bin/composer(29): require('...')
#4 {main}
  thrown in phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/Process.php on line 98
[root@VM-16-6-centos config]# 

然后我去宝塔里面对PHP进行重载配置重启,并且删除了禁用函数putenv proc_open,然后安装了fileinfo扩展

再次运行更新composer composer self-update

再次运行开启多应用 composer require topthink/think-multi-app

此时没有报错了。

3.快速安装应用

直接终端运行php think build admin

当你看到 Successed 时候,表示你已经成功创建应用