# micro-bees **Repository Path**: guominglei/micro-bees ## Basic Information - **Project Name**: micro-bees - **Description**: MicroBees 是用Yii2框架搭建的API模板 [Yii 2](http://www.yiiframework.com/) . - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-09-28 - **Last Updated**: 2024-10-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

MicroBees is a Yii2 API Template


MicroBees 是用Yii2框架搭建的API模板 [Yii 2](http://www.yiiframework.com/) . ## 目录说明 ``` api components/ api组件类目录 config/ api配置 controllers/ 控制器类存放目录 models/ 公共模型类和表单类目录 模型类与数据库表一一对应 modules/ 模块分类目录 runtime/ 运行时目录 web/ Web 应用根目录,包含 Web 入口文件 index.php 应用入口文件 common actions/ 公共控制器动作类目录 components/ 公共组件类目录 config/ 公共配置 language/ 国际化语言相关 models/ 公共模型类和表单类目录 模型类与数据库表一一对应 common config/ 公共配置 mail/ 邮件视图view存放目录 models/ 公共模型类和表单类目录 模型类与数据库表一一对应 tests/ 测试相关:如单元测试 console config/ 控制台配置 controllers/ 控制台控制器类存放目录 (commands) migrations/ 数据库迁移文件目录 models/ 控制台模型类目录 runtime/ 运行时目录 vendor/ composer第三方依赖包目录 docs/ 文档目录 yii Yii控制台命令入口(linux):如shell控制台下运行php yii 可以看到yii命令的帮助说明 ``` ## 安装说明 ### 克隆仓库代码到本地 假如项目安装地址是micro_bees,进入项目目录,运行命令git clone https://gitee.com/guominglei/micro-bees.git ```shell cd micro_bees git clone https://gitee.com/guominglei/micro-bees.git ``` ### 安装依赖包 进入项目目录,运行命令composer install ```shell cd micro_bees composer install ``` ### 配置数据库和缓存 到common\config目录下,main-local.php配置文件,配置好数据库账号密码等。缓存组件建议使用memcache或redis。 ``` [ // 配置数据库组件 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1;dbname=bees', // 数据库连接 'username' => 'bees', // 数据库账号 'password' => '123456', // 数据库账号密码 'charset' => 'utf8', // 数据库连接字符集 'tablePrefix' => 'bees_', // 表前缀 ], ] ]; ``` ### 配置web服务器 Api接口 nginx配置如: ``` server { listen 80; server_name micro-bees.local; root "/home/www/micro_bees/api/web"; location / { index index.html index.htm index.php; try_files $uri $uri/ /index.php$is_args$args; #autoindex on; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } } ``` ### 数据库迁移 在当前代码根目录下,运行控制台命令php yii migrate迁移数据库, 选项yes安装全部迁移。 ``` $ php yii migrate ``` ### 打开浏览器,访问:yourhost.com