企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Yii2 \#[ yii2官方手册](https://github.com/yiisoft/yii2/tree/master/docs/guide-zh-CN) ``` <pre class="calibre14">``` composer global require <span class="token4">"fxp/composer-asset-plugin:^1.2.0"</span> composer create<span class="token">-</span>project <span class="token">--</span>prefer<span class="token">-</span>dist yiisoft<span class="token">/</span>yii2<span class="token">-</span>app<span class="token">-</span>basic yii composer create<span class="token">-</span>project yiisoft<span class="token">/</span>yii2<span class="token">-</span>app<span class="token">-</span>advanced advanced <span class="token3">2.0</span><span class="token3">.15</span> ``` ``` 修改 config/web.php 文件 'cookieValidationKey' => '在此处输入你的密钥',然后再composer.json加上 去掉这个库,因为太大了几十MB ``` <pre class="calibre14">``` <span class="token4">"replace"</span><span class="token2">:</span> <span class="token2">{</span> <span class="token4">"bower-asset/punycode"</span><span class="token2">:</span> <span class="token4">">=1.3.0"</span><span class="token2">,</span> <span class="token2">}</span><span class="token2">,</span> ``` ``` 用composer update更新后就可以运行,定位到web/index.php 去掉index.php?r=site/about为site/about Apache,.htaccess ``` <pre class="calibre14">``` Options <span class="token">+</span>FollowSymLinks IndexIgnore <span class="token">*</span><span class="token6">/* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php </span> ``` ``` 在config/web.php去掉注释 urlManager字段注释即可 目录结构 ``` <pre class="calibre16">``` basic<span class="token">/</span> 应用根目录 composer<span class="token2">.</span>json Composer 配置文件<span class="token2">,</span> 描述包信息 config<span class="token">/</span> 包含应用配置及其它配置 console<span class="token2">.</span>php 控制台应用配置信息 web<span class="token2">.</span>php Web 应用配置信息 commands<span class="token">/</span> 包含控制台命令类 controllers<span class="token">/</span> 包含控制器类 models<span class="token">/</span> 包含模型类 runtime<span class="token">/</span> 包含 Yii 在运行时生成的文件,例如日志和缓存文件 vendor<span class="token">/</span> 包含已经安装的 Composer 包,包括 Yii 框架自身 views<span class="token">/</span> 包含视图文件 web<span class="token">/</span> Web 应用根目录,包含 Web 入口文件 assets<span class="token">/</span> 包含 Yii 发布的资源文件(javascript 和 css) index<span class="token2">.</span>php 应用入口文件 yii Yii 控制台命令执行脚本 ``` ```