HBuilderX

HBuilderX

极客开发工具
uni-app

uni-app

开发一次,多端覆盖
uniCloud

uniCloud

云开发平台
HTML5+

HTML5+

增强HTML5的功能体验
MUI

MUI

上万Star的前端框架

贵阳创业公司诚聘前端开发工程师

招聘

薪资:4K-6K
要求:
一年及以上实际工作经验
精通JS、CSS
独立根据用户需求进行应用设计并实现,完美实现UI设计稿
熟练运用各类主流框架
有使用Vue或uniapp开发和应用上线经验
有意者欢迎联系QQ:2455212990或电话:13123616566

继续阅读 »

薪资:4K-6K
要求:
一年及以上实际工作经验
精通JS、CSS
独立根据用户需求进行应用设计并实现,完美实现UI设计稿
熟练运用各类主流框架
有使用Vue或uniapp开发和应用上线经验
有意者欢迎联系QQ:2455212990或电话:13123616566

收起阅读 »

应用程序开发模式的具体区别是什么?

混合开发 小程序

如今移动互联网发展迅速,大家都在用智能手机,所以很多企业都在开发自己的app产品,我们经常用的微信、支付宝、微博、抖音等都是app产品,虽然很多人说开发app的作用不大,但还是有很多新的app产品出现,所以不是说app不受欢迎,而是之前很多app营销运营模式发生了变化,所以app所扮演的角色仍然很重要。

有哪些应用程序开发的模式呢?第一,本地开发,本地开发是基于安卓和ios平台的官方开发语言开发的,比如我们常用的java语言,c语言等等,大多数智能手机上安装的app都是本地app,需要用户自己下载,本地app有很多优点,比如运行速度快,功能多,用户体验好,功能还可以扩展,缺点就是成本比较高,后期版本更新需要用户更新。
还有一种应用程序开发的方式是使用web语言开发的,通过移动设备上面的浏览器来访问和使用,web开发的app费用较低,并且可以在线使用,另外支持许多移动设备,但也有许多缺点,比如打开速度慢,因为是基于浏览器访问的,还有一点就是功能很少,可以说没有公众号和小程序实用,还有就是很难在手机上调用某些功能,所以如果想要更实用的话,建议不要开发webapp。
另外一种app开发方式也是有用户使用的,即混合app开发,简单地说就是把原生app和H5两种开发技术结合在一起开发的app,具体的比例可以根据难易程度而定,没有标准的比例,混合开发的app优点是与许多平台兼容,比web端的app实现更多的功能,还有一个优势就是可以离线使用,缺点是目前的app开发技术还不够成熟,性能不如原生app,所以如果想要开发更好的app应用,还是应该考虑原生app开发。
本文来源:标梵互动

继续阅读 »

如今移动互联网发展迅速,大家都在用智能手机,所以很多企业都在开发自己的app产品,我们经常用的微信、支付宝、微博、抖音等都是app产品,虽然很多人说开发app的作用不大,但还是有很多新的app产品出现,所以不是说app不受欢迎,而是之前很多app营销运营模式发生了变化,所以app所扮演的角色仍然很重要。

有哪些应用程序开发的模式呢?第一,本地开发,本地开发是基于安卓和ios平台的官方开发语言开发的,比如我们常用的java语言,c语言等等,大多数智能手机上安装的app都是本地app,需要用户自己下载,本地app有很多优点,比如运行速度快,功能多,用户体验好,功能还可以扩展,缺点就是成本比较高,后期版本更新需要用户更新。
还有一种应用程序开发的方式是使用web语言开发的,通过移动设备上面的浏览器来访问和使用,web开发的app费用较低,并且可以在线使用,另外支持许多移动设备,但也有许多缺点,比如打开速度慢,因为是基于浏览器访问的,还有一点就是功能很少,可以说没有公众号和小程序实用,还有就是很难在手机上调用某些功能,所以如果想要更实用的话,建议不要开发webapp。
另外一种app开发方式也是有用户使用的,即混合app开发,简单地说就是把原生app和H5两种开发技术结合在一起开发的app,具体的比例可以根据难易程度而定,没有标准的比例,混合开发的app优点是与许多平台兼容,比web端的app实现更多的功能,还有一个优势就是可以离线使用,缺点是目前的app开发技术还不够成熟,性能不如原生app,所以如果想要开发更好的app应用,还是应该考虑原生app开发。
本文来源:标梵互动

收起阅读 »

关于H5和uniapp中webview通信(踩坑日记)

在uniapp中webview会变成一个iframe,用uni.postMessage传递参数的时候在webview使用@message实际上是接收不到参数的,文档中又说可以使用$emit和$on,我亲测是不行,不排除我可能写错了吧。分享一下我的解决办法:
H5页面依旧是使用uni.postMessage,只是在web-view的页面要使用 window.addEventListener("message", this.receviceMsg);这里this.receviceMsg是@messgae调用的方法名~@message可以不需要啦!!!希望对大家有用~

继续阅读 »

在uniapp中webview会变成一个iframe,用uni.postMessage传递参数的时候在webview使用@message实际上是接收不到参数的,文档中又说可以使用$emit和$on,我亲测是不行,不排除我可能写错了吧。分享一下我的解决办法:
H5页面依旧是使用uni.postMessage,只是在web-view的页面要使用 window.addEventListener("message", this.receviceMsg);这里this.receviceMsg是@messgae调用的方法名~@message可以不需要啦!!!希望对大家有用~

收起阅读 »

国产社区都这么流氓吗????

git可以直接下载,gitee必须注册才能下载~
然后这个论坛,绑定了手机号还要强制绑邮箱才能发帖?

管理者心态太差了吧???

git可以直接下载,gitee必须注册才能下载~
然后这个论坛,绑定了手机号还要强制绑邮箱才能发帖?

管理者心态太差了吧???

关于MacOS 10.13.6系统,2.9.7正式版,运行ios真机,提示mdb错误的解决方案。

HBuilderX

此帖子仅仅适用于HBuilderX 2.9.7版本,不适用于其它版本。其它HBuilderX版本请忽略此贴。


关于MacOS 10.13.6系统,2.9.7正式版,运行ios真机,提示mdb错误的解决方案。

环境

MacOSX: 10.13.6系统
HBuilderX: 2.9.7正式版
手机系统:ios

问题

运行ios真机,提示mdb错误,具体错误如下:

Library not loaded: @executable_path/lib/libplist.3.dylib  
Referenced from: /Applications/HBuilderX.app/Contents/HBuilderX/plugins/launcher/tools/mdb/mdb  
Reason: Incompatible library version: mdb requires version 7.0.0 or later, but libplist.3.dylib provides version 5.0.0

受影响的操作系统

影响范围: MacOSX 10.13.6。

MacOSX 10.14.X, 10.15.X, 11.0.X, 不受影响。

原因

2020年10月,为了解决MacOSX big sur 11操作系统无法连接ios真机的问题,引出的新问题。

解决方案

下载附件中的mdb.zip,替换本机的mdb。

正式版替换路径:

/Applications/HBuilderX.app/Contents/HBuilderX/plugins/launcher/tools/mdb

alpha版本替换路径:

/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/launcher/tools/mdb

MacOSX big sur 11.0.1 beta版本, 连接模拟器或android真机出错的解决方案

下载此ls.jar,替换本机的ls.jar. 下载地址:macosx big sur 11 beta ls.jar 下载地址

备注:替换前,要关闭HBuilderX

正式版替换路径:

/Applications/HBuilderX.app/Contents/HBuilderX/plugins/ls

alpha版本替换路径:

/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/ls
继续阅读 »

此帖子仅仅适用于HBuilderX 2.9.7版本,不适用于其它版本。其它HBuilderX版本请忽略此贴。


关于MacOS 10.13.6系统,2.9.7正式版,运行ios真机,提示mdb错误的解决方案。

环境

MacOSX: 10.13.6系统
HBuilderX: 2.9.7正式版
手机系统:ios

问题

运行ios真机,提示mdb错误,具体错误如下:

Library not loaded: @executable_path/lib/libplist.3.dylib  
Referenced from: /Applications/HBuilderX.app/Contents/HBuilderX/plugins/launcher/tools/mdb/mdb  
Reason: Incompatible library version: mdb requires version 7.0.0 or later, but libplist.3.dylib provides version 5.0.0

受影响的操作系统

影响范围: MacOSX 10.13.6。

MacOSX 10.14.X, 10.15.X, 11.0.X, 不受影响。

原因

2020年10月,为了解决MacOSX big sur 11操作系统无法连接ios真机的问题,引出的新问题。

解决方案

下载附件中的mdb.zip,替换本机的mdb。

正式版替换路径:

/Applications/HBuilderX.app/Contents/HBuilderX/plugins/launcher/tools/mdb

alpha版本替换路径:

/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/launcher/tools/mdb

MacOSX big sur 11.0.1 beta版本, 连接模拟器或android真机出错的解决方案

下载此ls.jar,替换本机的ls.jar. 下载地址:macosx big sur 11 beta ls.jar 下载地址

备注:替换前,要关闭HBuilderX

正式版替换路径:

/Applications/HBuilderX.app/Contents/HBuilderX/plugins/ls

alpha版本替换路径:

/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/ls
收起阅读 »

Solarized Dark——HBuilder X主题

主题 HBuilder


主题:雅蓝
设置方法:修改Settings.json,保存,重启

{  
    "theme-custom.name": "Solarized Dark",  
    "theme-custom.author": "cxjfun",  
    "theme-custom.version": "0.0.1",  
    "theme-custom.date": "2020-11-06",  
    "editor.colorScheme": "Atom One Dark",  
    "workbench.colorCustomizations": {  
        "[Atom One Dark]": {  
            "button.background": "#16825d",  
            "button.foreground": "#ffffff",  
            "button.hoverBackground": "#329171",  
            "console.background": "#1e1e1e",  
            "debug.foreground": "#008cb3",  
            "editor.background": "#002b37",  
            "editor.foreground": "#fff",  
            "editorGroup.border": "#37575e",  
            "editorSuggestWidget.background": "#002b36",  
            "editorSuggestWidget.border": "#004052",  
            "editorSuggestWidget.link": "#16825d",  
            "editorSuggestWidget.selectedBackground": "#005a6f",  
            "extensionButton.border": "#16825d",  
            "extensionButton.checkColor": "#ffffff",  
            "extensionButton.prominentBackground": "#16825d",  
            "extensionButton.prominentForeground": "#fff3d5",  
            "extensionButton.prominentHoverBackground": "#329171",  
            "focusBorder": "#00b4e6",  
            "input.background": "#003847",  
            "input.border": "#003847",  
            "input.foreground": "#ffffff",  
            "inputList.border": "#00212b",  
            "inputList.foreground": "#3c3c3c",  
            "inputList.hoverBackground": "#003847",  
            "inputList.titleColor": "#ffffff",  
            "inputOption.activeBorder": "#16825d",  
            "inputValidation.infoBackground": "#00212b",  
            "list.activeSelectionBackground": "#005a6f",  
            "list.foreground": "#ffffff",  
            "list.highlightForeground": "#ffffff",  
            "list.hoverBackground": "#003946",  
            "minimap.handle.background": "#004052",  
            "notificationLink.foreground": "#16825d",  
            "notifications.background": "#003847",  
            "notifications.border": "#003847",  
            "outlineBackground": "#00212b",  
            "panelTitle.activeForeground": "#008cb3",  
            "scrollbarSlider.background": "#304a50",  
            "scrollbarSlider.hoverBackground": "#465356",  
            "settings.dropdownBackground": "#002b36",  
            "settings.dropdownBorder": "#16825d",  
            "settings.dropdownForeground": "#ffffff",  
            "settings.dropdownListBorder": "#002b36",  
            "settings.textInputBackground": "#00212b",  
            "settings.textInputBorder": "#002b36",  
            "settings.textInputDisableBackground": "#002b36",  
            "sideBar.background": "#004052",  
            "sideBar.border": "#004052",  
            "statusBar.background": "#006480",  
            "statusBar.foreground": "#ffffff",  
            "tab.activeBackground": "#002b37",  
            "tab.activeForeground": "#ffffff",  
            "tab.border": "#002b37",  
            "tab.hoverBackground": "#004052",  
            "tab.inactiveBackground": "#004052",  
            "tab.inactiveForeground": "#999999",  
            "terminal.background": "#00212b",  
            "toolBar.background": "#003847",  
            "toolBar.border": "#003847",  
            "toolBar.hoverBackground": "#003847"  
        }  
    },  
    "explorer.iconTheme": "vs-seti"  
}

继续阅读 »


主题:雅蓝
设置方法:修改Settings.json,保存,重启

{  
    "theme-custom.name": "Solarized Dark",  
    "theme-custom.author": "cxjfun",  
    "theme-custom.version": "0.0.1",  
    "theme-custom.date": "2020-11-06",  
    "editor.colorScheme": "Atom One Dark",  
    "workbench.colorCustomizations": {  
        "[Atom One Dark]": {  
            "button.background": "#16825d",  
            "button.foreground": "#ffffff",  
            "button.hoverBackground": "#329171",  
            "console.background": "#1e1e1e",  
            "debug.foreground": "#008cb3",  
            "editor.background": "#002b37",  
            "editor.foreground": "#fff",  
            "editorGroup.border": "#37575e",  
            "editorSuggestWidget.background": "#002b36",  
            "editorSuggestWidget.border": "#004052",  
            "editorSuggestWidget.link": "#16825d",  
            "editorSuggestWidget.selectedBackground": "#005a6f",  
            "extensionButton.border": "#16825d",  
            "extensionButton.checkColor": "#ffffff",  
            "extensionButton.prominentBackground": "#16825d",  
            "extensionButton.prominentForeground": "#fff3d5",  
            "extensionButton.prominentHoverBackground": "#329171",  
            "focusBorder": "#00b4e6",  
            "input.background": "#003847",  
            "input.border": "#003847",  
            "input.foreground": "#ffffff",  
            "inputList.border": "#00212b",  
            "inputList.foreground": "#3c3c3c",  
            "inputList.hoverBackground": "#003847",  
            "inputList.titleColor": "#ffffff",  
            "inputOption.activeBorder": "#16825d",  
            "inputValidation.infoBackground": "#00212b",  
            "list.activeSelectionBackground": "#005a6f",  
            "list.foreground": "#ffffff",  
            "list.highlightForeground": "#ffffff",  
            "list.hoverBackground": "#003946",  
            "minimap.handle.background": "#004052",  
            "notificationLink.foreground": "#16825d",  
            "notifications.background": "#003847",  
            "notifications.border": "#003847",  
            "outlineBackground": "#00212b",  
            "panelTitle.activeForeground": "#008cb3",  
            "scrollbarSlider.background": "#304a50",  
            "scrollbarSlider.hoverBackground": "#465356",  
            "settings.dropdownBackground": "#002b36",  
            "settings.dropdownBorder": "#16825d",  
            "settings.dropdownForeground": "#ffffff",  
            "settings.dropdownListBorder": "#002b36",  
            "settings.textInputBackground": "#00212b",  
            "settings.textInputBorder": "#002b36",  
            "settings.textInputDisableBackground": "#002b36",  
            "sideBar.background": "#004052",  
            "sideBar.border": "#004052",  
            "statusBar.background": "#006480",  
            "statusBar.foreground": "#ffffff",  
            "tab.activeBackground": "#002b37",  
            "tab.activeForeground": "#ffffff",  
            "tab.border": "#002b37",  
            "tab.hoverBackground": "#004052",  
            "tab.inactiveBackground": "#004052",  
            "tab.inactiveForeground": "#999999",  
            "terminal.background": "#00212b",  
            "toolBar.background": "#003847",  
            "toolBar.border": "#003847",  
            "toolBar.hoverBackground": "#003847"  
        }  
    },  
    "explorer.iconTheme": "vs-seti"  
}

收起阅读 »

离线推送,第三方厂商推送

走了不少弯路,写出来分享给大家,希望更多的人不要像我这像浪费时间了
直接上代码吧,

//app.vue中执行该方法
export function bindMsgClick(){
//监听系统通知栏消息点击事件
plus.push.addEventListener('click', function(msg){
//处理点击消息的业务逻辑代码
//{title:"标题",content:"内容",payload:"自定义数据"}
console.log(msg)
uni.navigateTo({
url: '///?reflush=true'
})
}, false);
plus.push.addEventListener('receive', function(msg){
plus.push.createMessage(msg.content, message.payload, {
title: message.title
})
});
}

//登录成功之后绑定cid
export function updateCid(){
var pinf = plus.push.getClientInfo();
console.log('client',pinf.clientid)
request.post("/**/",{client:pinf.clientid}).then(res=>{
console.log(res.data)
});
}

后端代码如下,

//发消息给个人
public static String sendMsg(String clientId){
// 获取应用基本信息
IGtPush push = new IGtPush(host, appKey, masterSecret);
// 选择透传通知模板,个推离线只支持透传
TransmissionTemplate template = new TransmissionTemplate();
template.setAppId(appId);
template.setAppkey(appKey);

    JSONObject msg = new JSONObject();  
    msg.put("title","离线消息测试");  
    msg.put("content","---离线消息测试---");  

    String payload = msg.toString();  
    template.setTransmissionContent(payload);    // 设置透传内容  
    template.setTransmissionType(2);    // 2代表客户端收到消息后需要自行处理  

    // 配置第三方厂商推送  
    Notify notify = new Notify();  
    notify.setTitle(msg.getString("title"));  
    notify.setContent(msg.getString("content"));  
    notify.setType(GtReq.NotifyInfo.Type._intent);  
    // 设置intent 注意格式要正确(修改你的包名)  
    notify.setIntent("intent:#Intent;launchFlags=0x04000000;action=android.intent.action.oppopush;" +  
        "package=uni.包名.包名;" +  
        "component=uni.包名.包名/io.dcloud.PandoraEntry;S.UP-OL-SU=true;" +  
        "S.title=" + msg.getString("title") + ";" +  
        "S.content="+ msg.getString("content") + ";" +  
        "S.payload=" + payload + ";end");  
    notify.setPayload(payload);  
    template.set3rdNotifyInfo(notify);  

    List<String> appIds = new ArrayList<>();  
    appIds.add(appId);  
    SingleMessage message = new SingleMessage();  
    message.setData(template);  
    message.setOffline(true);  
    message.setOfflineExpireTime(8* 1000 * 3600);    // 离线有效时间 单位毫秒  
    message.setStrategyJson("{\"default\":4}");  
    Target target = new Target();  
    target.setAppId(appId);  
    target.setClientId(clientId);  
    IPushResult ret = null;  
    try {  
        ret = push.pushMessageToSingle(message, target);  
    } catch (RequestException e) {  
        e.printStackTrace();  
        ret = push.pushMessageToSingle(message, target, e.getRequestId());  
    }  
    if (ret != null) {  
        System.out.println(ret.getResponse().toString());  
        return ret.getResponse().toString();  
    } else {  
        System.out.println("服务器响应异常");  
        return "服务器响应异常";  
    }  
}  

在后台配置好自己申请的第三方厂商的key,就可以杀掉app进程,向app推送消息了
目前只在小米手机上测试通过了

继续阅读 »

走了不少弯路,写出来分享给大家,希望更多的人不要像我这像浪费时间了
直接上代码吧,

//app.vue中执行该方法
export function bindMsgClick(){
//监听系统通知栏消息点击事件
plus.push.addEventListener('click', function(msg){
//处理点击消息的业务逻辑代码
//{title:"标题",content:"内容",payload:"自定义数据"}
console.log(msg)
uni.navigateTo({
url: '///?reflush=true'
})
}, false);
plus.push.addEventListener('receive', function(msg){
plus.push.createMessage(msg.content, message.payload, {
title: message.title
})
});
}

//登录成功之后绑定cid
export function updateCid(){
var pinf = plus.push.getClientInfo();
console.log('client',pinf.clientid)
request.post("/**/",{client:pinf.clientid}).then(res=>{
console.log(res.data)
});
}

后端代码如下,

//发消息给个人
public static String sendMsg(String clientId){
// 获取应用基本信息
IGtPush push = new IGtPush(host, appKey, masterSecret);
// 选择透传通知模板,个推离线只支持透传
TransmissionTemplate template = new TransmissionTemplate();
template.setAppId(appId);
template.setAppkey(appKey);

    JSONObject msg = new JSONObject();  
    msg.put("title","离线消息测试");  
    msg.put("content","---离线消息测试---");  

    String payload = msg.toString();  
    template.setTransmissionContent(payload);    // 设置透传内容  
    template.setTransmissionType(2);    // 2代表客户端收到消息后需要自行处理  

    // 配置第三方厂商推送  
    Notify notify = new Notify();  
    notify.setTitle(msg.getString("title"));  
    notify.setContent(msg.getString("content"));  
    notify.setType(GtReq.NotifyInfo.Type._intent);  
    // 设置intent 注意格式要正确(修改你的包名)  
    notify.setIntent("intent:#Intent;launchFlags=0x04000000;action=android.intent.action.oppopush;" +  
        "package=uni.包名.包名;" +  
        "component=uni.包名.包名/io.dcloud.PandoraEntry;S.UP-OL-SU=true;" +  
        "S.title=" + msg.getString("title") + ";" +  
        "S.content="+ msg.getString("content") + ";" +  
        "S.payload=" + payload + ";end");  
    notify.setPayload(payload);  
    template.set3rdNotifyInfo(notify);  

    List<String> appIds = new ArrayList<>();  
    appIds.add(appId);  
    SingleMessage message = new SingleMessage();  
    message.setData(template);  
    message.setOffline(true);  
    message.setOfflineExpireTime(8* 1000 * 3600);    // 离线有效时间 单位毫秒  
    message.setStrategyJson("{\"default\":4}");  
    Target target = new Target();  
    target.setAppId(appId);  
    target.setClientId(clientId);  
    IPushResult ret = null;  
    try {  
        ret = push.pushMessageToSingle(message, target);  
    } catch (RequestException e) {  
        e.printStackTrace();  
        ret = push.pushMessageToSingle(message, target, e.getRequestId());  
    }  
    if (ret != null) {  
        System.out.println(ret.getResponse().toString());  
        return ret.getResponse().toString();  
    } else {  
        System.out.println("服务器响应异常");  
        return "服务器响应异常";  
    }  
}  

在后台配置好自己申请的第三方厂商的key,就可以杀掉app进程,向app推送消息了
目前只在小米手机上测试通过了

收起阅读 »

H5 UDP客户端(安卓) 含接收、发送、中文消息

UDP

首先,我是在大佬的提示下,综合了一下,在安卓上解决了H5 UDP接收消息和发送消息的问题,而且中文也解决了。

我把代码发到CSDN上文章上了,点击这里,真实可用哦,

继续阅读 »

首先,我是在大佬的提示下,综合了一下,在安卓上解决了H5 UDP接收消息和发送消息的问题,而且中文也解决了。

我把代码发到CSDN上文章上了,点击这里,真实可用哦,

收起阅读 »

小程序端 自定义组件中 使用 model用法不生效 解决方案

示例代码:
自定义组件
组件名称 demo
model:{
prop:"value",
event:"input" //小程序只支持自定义方法为 input 其他不支持
},
父组件
<view>
<demo v-model="child">

          </demo>  
     </view>  

解决方案 自定义事件 小程序只支持input 其他名字暂不支持

继续阅读 »

示例代码:
自定义组件
组件名称 demo
model:{
prop:"value",
event:"input" //小程序只支持自定义方法为 input 其他不支持
},
父组件
<view>
<demo v-model="child">

          </demo>  
     </view>  

解决方案 自定义事件 小程序只支持input 其他名字暂不支持

收起阅读 »

便携式蓝牙打印,研究了很长时间,终于打印出来了,现在分享经验,省的少走弯路

微信小程序 蓝牙打印

说多了都是泪,开始也是拿别人的demo来打印,发现不是这里不对就是哪里不对,基本上都打印不出来,研究了一段时间,各种模式的指令都研究了ESC,TSPL,CPCL,最终用的是CPCL,因为这个最通俗易懂,最主要的是打印图片最麻烦,走了好多弯路。用的是佳博和芝柯的

京东
顺丰
邮政
中通

代码是从项目中扒出来的,不保证能运行,但是打印的逻辑和指令是可以参考的

继续阅读 »

说多了都是泪,开始也是拿别人的demo来打印,发现不是这里不对就是哪里不对,基本上都打印不出来,研究了一段时间,各种模式的指令都研究了ESC,TSPL,CPCL,最终用的是CPCL,因为这个最通俗易懂,最主要的是打印图片最麻烦,走了好多弯路。用的是佳博和芝柯的

京东
顺丰
邮政
中通

代码是从项目中扒出来的,不保证能运行,但是打印的逻辑和指令是可以参考的

收起阅读 »

手把手告诉你如何用扩展开发PHP7?

PHP

本教程以PHP7为基础,说明如何从零开始扩展PHP7.3。
第一步:准备工作
1、基础环境:
PHP 7.3.19-1+ubuntu16.04.1
2、安装php开发版:
apt install php7.3.1-dev
3、下载相关事项:
①下载php源码
②linux可用命令下载
③下载源码所放目录(可自定):
/usr/local/src/
手把手告诉你如何用扩展开发PHP7?

第二步:解压源码压缩包
1、tar -zxvf php-7.3.19.tar.gz (如下载的是bz2后缀的,用tar -xjf文件名)
2、文件说明
①大致只需关注Zend和ext这两个目录;
②Zend目录里包含PHP的Zend Engine源代码;
③ext目录里包含PHP原生的扩展,以及我们开发自己的扩展时可以利用的ext_skel.php脚本工具;
④php7.3之前版本Linux下使用ext_skel,Windows下使用ext_skel_win32.php;
⑤php7.3后用ext_skel.php。
第三步:使用ext_skel.php脚本工具创建扩展骨架
cd ext
php ext_skel.php --ext helloWorld
第四步:修改config.m4文件
cd helloworld
可以看到config.m4文件,打开找到这样的代码
dnl PHP_ARG_WITH(helloworld, for helloworld support,
dnl Make sure that the comment is aligned:
dnl [ --with-helloworld Include helloworld support])
把开头的“dnl ”都去掉,改为
PHP_ARG_WITH(helloworld, for helloworld support,
Make sure that the comment is aligned:
[ --with-helloworld Include helloworld support])
备注:
①PHP_ARG_WITH和PHP_ARG_ENABLE这两个宏用来配置configure选项,一个配置需要外部依赖的,另一个配置不需要外部依赖的配置好的内容,在后面执行configure --help时可以看到;
②php_hello.h头文件类似于C语言的头文件,包含了一些自定义的结构和函数声明,在这个demo中暂时不需要改动;
③hello.c代码文件真正的逻辑代码都在这个文件中。
第五步:进行编译
1、操作
phpize
./configure
make
make install
2、编译完成后
把对应的helloworld.so添加到php.in(vim /etc/php/7.3/cli/php.ini)扩展中就能使用了:extension =helloworld.so
3、检验扩展是否安装成功
使用 php -m 查看helloworld扩展是否已经安装成功
第六步:创建HelloWorld示例
1、了解helloworld.c文件
整个扩展的入口是helloworld_module_entry
备注:
①STANDARD_MODULE_HEADER帮我们实现了前面6个属性;
②"helloworld"是扩展的名字;
③helloworld_functions是扩展包含的全部方法的集合;
④后面5个宏分别代表5个扩展特定方法;
⑤PHP_HELLO_VERSION是扩展的版本号,定义在头文件中;
⑥STANDARD_MODULE_PROPERTIES帮我们实现了剩下的属性;
⑦本次这个都不需要修改,按照这个入口添加扩展方法。
2、编写hellp_world示例
在helloworld_functions[]方法数组中已经有了两个示例方法;
helloworld_test[1|2],我们参考它写我们的方法hello_world。
先在扩展的方法数组中添加上hello_world,然后再定义hello_world;
找到helloworld_test1方法定义的地方,类似这样的再创建一个;
hello_world方法,php_printf是Zend Engine中的printf方法。
3、重新编译
phpize
./configure
make
make install
4、执行hello_world()
php -a 进入到交互模式
hello_world();
以上就是通过Linux命令行的使用和创建PHP扩展的全部内容。
本文来源:标梵互动(https://www.biaofun.com/)

继续阅读 »

本教程以PHP7为基础,说明如何从零开始扩展PHP7.3。
第一步:准备工作
1、基础环境:
PHP 7.3.19-1+ubuntu16.04.1
2、安装php开发版:
apt install php7.3.1-dev
3、下载相关事项:
①下载php源码
②linux可用命令下载
③下载源码所放目录(可自定):
/usr/local/src/
手把手告诉你如何用扩展开发PHP7?

第二步:解压源码压缩包
1、tar -zxvf php-7.3.19.tar.gz (如下载的是bz2后缀的,用tar -xjf文件名)
2、文件说明
①大致只需关注Zend和ext这两个目录;
②Zend目录里包含PHP的Zend Engine源代码;
③ext目录里包含PHP原生的扩展,以及我们开发自己的扩展时可以利用的ext_skel.php脚本工具;
④php7.3之前版本Linux下使用ext_skel,Windows下使用ext_skel_win32.php;
⑤php7.3后用ext_skel.php。
第三步:使用ext_skel.php脚本工具创建扩展骨架
cd ext
php ext_skel.php --ext helloWorld
第四步:修改config.m4文件
cd helloworld
可以看到config.m4文件,打开找到这样的代码
dnl PHP_ARG_WITH(helloworld, for helloworld support,
dnl Make sure that the comment is aligned:
dnl [ --with-helloworld Include helloworld support])
把开头的“dnl ”都去掉,改为
PHP_ARG_WITH(helloworld, for helloworld support,
Make sure that the comment is aligned:
[ --with-helloworld Include helloworld support])
备注:
①PHP_ARG_WITH和PHP_ARG_ENABLE这两个宏用来配置configure选项,一个配置需要外部依赖的,另一个配置不需要外部依赖的配置好的内容,在后面执行configure --help时可以看到;
②php_hello.h头文件类似于C语言的头文件,包含了一些自定义的结构和函数声明,在这个demo中暂时不需要改动;
③hello.c代码文件真正的逻辑代码都在这个文件中。
第五步:进行编译
1、操作
phpize
./configure
make
make install
2、编译完成后
把对应的helloworld.so添加到php.in(vim /etc/php/7.3/cli/php.ini)扩展中就能使用了:extension =helloworld.so
3、检验扩展是否安装成功
使用 php -m 查看helloworld扩展是否已经安装成功
第六步:创建HelloWorld示例
1、了解helloworld.c文件
整个扩展的入口是helloworld_module_entry
备注:
①STANDARD_MODULE_HEADER帮我们实现了前面6个属性;
②"helloworld"是扩展的名字;
③helloworld_functions是扩展包含的全部方法的集合;
④后面5个宏分别代表5个扩展特定方法;
⑤PHP_HELLO_VERSION是扩展的版本号,定义在头文件中;
⑥STANDARD_MODULE_PROPERTIES帮我们实现了剩下的属性;
⑦本次这个都不需要修改,按照这个入口添加扩展方法。
2、编写hellp_world示例
在helloworld_functions[]方法数组中已经有了两个示例方法;
helloworld_test[1|2],我们参考它写我们的方法hello_world。
先在扩展的方法数组中添加上hello_world,然后再定义hello_world;
找到helloworld_test1方法定义的地方,类似这样的再创建一个;
hello_world方法,php_printf是Zend Engine中的printf方法。
3、重新编译
phpize
./configure
make
make install
4、执行hello_world()
php -a 进入到交互模式
hello_world();
以上就是通过Linux命令行的使用和创建PHP扩展的全部内容。
本文来源:标梵互动(https://www.biaofun.com/)

收起阅读 »