多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# **php版本要求:** ``` PHP >= 7.1.0 ``` # **安装:** ## **更换镜像源** ~~~ composer config -g repo.packagist composer https://packagist.phpcomposer.com ~~~ 或者 ~~~ composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ ~~~ ## **compoer安装:** >[info] **安装稳定版** 如果你是第一次安装的话,在命令行下面,切换到你的WEB根目录下面并执行下面的命令: ~~~ composer create-project topthink/think tp6 ~~~ 这里的`tp6`目录名你可以任意更改,这个目录就是我们后面会经常提到的应用根目录 此安装包含默认的插件包 ``` Package operations: 15 installs, 0 updates, 0 removals - Installing topthink/think-helper (v3.1.5): Downloading (100%) - Installing psr/log (1.1.4): Downloading (100%) - Installing psr/simple-cache (1.0.1): Downloading (100%) - Installing topthink/think-orm (v2.0.44): Downloading (100%) - Installing symfony/polyfill-php80 (v1.23.1): Downloading (100%) - Installing symfony/polyfill-php72 (v1.23.0): Downloading (100%) - Installing symfony/polyfill-mbstring (v1.23.1): Downloading (100%) - Installing symfony/var-dumper (v4.4.27): Downloading (100%) - Installing psr/container (1.1.1): Downloading (100%) - Installing psr/cache (1.0.1): Downloading (100%) - Installing league/mime-type-detection (1.7.0): Downloading (100%) - Installing league/flysystem (1.1.4): Downloading (100%) - Installing league/flysystem-cached-adapter (1.1.0): Downloading (100%) - Installing topthink/framework (v6.0.9): Downloading (100%) - Installing topthink/think-trace (v1.4): Downloading (100%) ``` >[info] **安装稳定版(核心库?)** ``` composer update topthink/framework ``` >[info] 安装开发版 ~~~ composer create-project topthink/think tp 6.0.x-dev tp6 ~~~ >[info] **cd进入上面的tp6目录 更新核心库** ~~~ composer update topthink/framework ~~~ ## **注意** >[danger] 1.在实际的部署中,请确保只有`public`目录可以对外访问。 2.在`mac`或者`linux`环境下面,注意需要`chmod -R 777 ./runtime`设置`runtime`目录权限为777。 3.如果将根目录设置为public后访问出现500错误,这时我们需要在php.ini设置`display_errors = on`和`display_startup_errors = on`,这时你可能会看到Warning:  **require(): open\_basedir restriction in effect.**的错误,这是因为linux下是不能跨目录访问的,我们只能访问到public及其子目录的内容,所以我们需要设置成能访问public同级及其子目录,假如网站根目录时public,如nginx设置为:root /home/wwwroot/tp5/public;通常情况下默认的值是`open_basedir = "/home/wwwroot/tp5/public/:/tmp/:/var/tmp/:/proc/` 所以我们要将将php.ini中的open_basedir参数改为`open_basedir = "/home/wwwroot/tp5/:/tmp/:/var/tmp/:/proc/"` 其他方法参见[跨目录设置](https://www.kancloud.cn/a173512/php_note/2399219) ## **安装think-view** 如果你需要使用`think-template`模板引擎,只需要安装`think-view`模板引擎驱动。 ~~~ composer require topthink/think-view ~~~ > 视图相关的配置在配置目录的`view.php`配置文件中进行定义。 通常可以直接使用`think\facade\View`来操作视图。 ## **安装多应用模式扩展** ``` composer require topthink/think-multi-app ``` ## **安装ORM扩展** >[danger]如果是nginx需要修改配置文件root项为public `location / {root /home/wwwroot/public}` `location ~ \.php$ {root /home/wwwroot/public}`:注意此选项需要启动php-fpm:`nohup ./php-fpm >test.log&` nginx默认不支持pathinfo访问模式的,我们需要额外的进行配置