vip 模块串讲

本文对VIP模块进行了全面串讲,包括新人专题快速入手和框架及业务代码的分析。重点介绍了部署配置,如SSH协议的使用、目录权限设置和Nginx配置。讲解了MobileFramework的结构,包括Load类的自动加载、Hooks类的钩子功能以及应用初始化。此外,还指出了框架和业务代码的不足,如DB类的链式操作不完善,并提出了重构建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

模块串讲
一. 新人专题快速入手
1.部署配置
http://gitlab.tools.vipshop.com/mst/mst-admin-front 拉代码,优先选择git原生支持的ssh协议,即git clone git@gitlab.tools.vipshop.com:mst/mst-admin-front.git 优点就是每次push 和pull 不用输入账号密码,而已速度更快,条件是要将开发电脑的ssh key 添加到gitlab
拉下来的代码目录要修改所有者和用户组,根据nginx的worker进程的所有者
这里写图片描述
和php-fpm 的子进程(与nginx保持一致)
这里写图片描述
所以这里是 chown -R www-data www-data mst-admin-front
这样才有足够权限读写,例如写日志,而不需要给文件777这种不安全的设置
nginx 的配置,看部分配置文件

server {
        listen       80;
        server_name  mst-admin.vip.vip.com;

        proxy_buffer_size   128k;
        proxy_buffers   4 256k;
        proxy_busy_buffers_size   256k;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        root   /Users/liuxing/www/mtms/branches/mtms_0525;
        location / {
            root   /Users/liuxing/www/mtms/branches/mtms_0525;
            index  admin.php;
        }
        rewrite  ^/css/(.+)$ /client/src/css/$1;
        rewrite  ^/common/(.+)$ /client/src/common/$1;
        rewrite ^/bower_component/(.+)$  /client/src/bower_component/$1;

        rewrite ^/api/(.+)$  /client/src/api/$1;
        rewrite ^/demo/(.+)$  /client/src/demo/$1;
        rewrite ^/module/(.+)$  /client/src/module/$1;
        rewrite ^/prototype/(.+)$ /client/src/prototype/$1;                

        set $flag 0;
        if ($request !~ "admin.php"){
            set $flag "${flag}1";
        }
        if (!-e $request_filename)
        {
            set $flag "${flag}2";
        }        
        if ($request ~ ([0-9]+)\.php(.*)$)
        {
            set $flag "${flag}3";
            rewrite ([0-9]+)\.php(.*)$ /index.php/Special/page?page_type_id=1&id=$1&$2;
        }
        if ($flag = "012")
        {
            rewrite ^/(.*)$ /index.php/$1;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;

            set $real_script_name $fastcgi_script_name;
            set $path_info "";
            if ( $fastcgi_script_name ~ "^(.+\.php)(/.+)$"){
                set $real_script_name $1;
                set $path_info $2;
            }

            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
            fastcgi_param PATH_INFO $path_info;
            include        fastcgi_params;
        }
    }

2.框架结构与开发流程
MobileFramework,较轻量的web框架,阅读源码比较容易,下面看admin的入口文件
调用了 MobileFramework::init(‘admin’);
核心代码是
require SYS_PATH.’/core/Load.class.php’;
require SYS_PATH.’/core/Hooks.class.php’;
Load::init

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值