1 Star 0 Fork 0

Vijay/cat_framework_demo_swoole

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

cat_framework_demo

介绍

喵框架支持swoole初始化代码,同时也是示例代码

安装教程

  1. 下载项目
    composer create-project dreamcat/cat_frame_demo_swoole
    
  2. 修改 composer.jsonname description authors autoload autoload-dev,注意,如果去除原有自动引入,现在的示例代码将无法执行,可以删除。
  3. 参考示例修改web容器配置。示例中php项目代码路径是 /home/php,相应前端路径 /home/static
    • Apache
    <VirtualHost *:80>
        DocumentRoot "/home/php"
        ServerName www.demo.com
        
        <Directory "/home/php">
            Require all granted
            AllowOverride All
            Allow from all
        </Directory>
        
        <IfModule mod_rewrite.c>
            RewriteEngine on
            RewriteRule ^(.*) /web.php [QSA,PT,L]
        </IfModule>
    </VirtualHost>
    
    • nginx
    server {
        listen       80;
        server_name  www.demo.com;
        index        index.html;
        root         /dev/null;
       
        # 首页指向前端,根据自己的业务需求调整
        location = / {
            rewrite ^/$ /static/ permanent; 
        }
        
        location /static/ {
          alias /home/static/dist/; 
          index index.html;
              
          location ~* \.(css|js|gif|jpe?g|png)$ {
              expires 1M;
              add_header Pragma public;
              add_header Cache-Control "public, must-revalidate, proxy-revalidate";
          }
        }
        
        # 接口服务器
        location /api {
          try_files $uri $uri/ /web.php?$query_string; 
        }
    
        location ~* \.php$ {
            fastcgi_pass     unix:/php/var/run/php_web.socket;
            fastcgi_index index.php;
            include fastcgi.conf;
            fastcgi_split_path_info ^(.+.php)(/.+)$;
            fastcgi_param SCRIPT_FILENAME /home/php/web.php;
            fastcgi_param HTTP_PROXY "";
        }    
    }
    
  4. 配置数据库、日志、路由,各环境一致的配置在 configs/config.php 中,随环境变化的配置放 cache/configs/config.php 中, 在swoole环境下使用的与FPM不一致的配置写在 configs/swooleModify.php 中,swoole 的启动配置在 configs/swoole.php
  5. 编写控制器逻辑

使用说明

可以参考示例的控制器和model,或者参考 wiki

建议参考示例中的分层,这样后续基建的工作就可以为之服务。不过如果是很简单的逻辑,也可以用简易方式即控制器完成一切的模式。

  • Controller下放控制器
  • Entry 下放 model 与数据库交互的实体对象
  • Model 下放 model
  • Pojo 下放控制器与外部交互的数据结构
  • Service 下放实现业务逻辑的 Service。
MIT License Copyright (c) 2019 Vijay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

喵框架swoole版本初始化代码,同时也是示例代码 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/vijay_0215/cat_framework_demo_swoole.git
git@gitee.com:vijay_0215/cat_framework_demo_swoole.git
vijay_0215
cat_framework_demo_swoole
cat_framework_demo_swoole
master

搜索帮助