当前位置:网站首页>Implement encapsulated public method global call in laravel framework
Implement encapsulated public method global call in laravel framework
2022-07-29 02:43:00 【Chenqing Nuo language】
1. establish functions.php
stay app/Helpers/ Next create a new file functions.php, Add the following code internally :
<?php
/**
* Common method return json data , Prompt for information
* @param $status state
* @param string $message Prompt information
* @param array $data Return the data
*/
function success($msg = '',$data = array()){
$result = array(
'code' => 20000,
'msg' =>$msg,
'data' =>$data
);
exit(json_encode($result));
}
function error($msg = '',$data = array()){
$result = array(
'code' => 50000,
'msg' =>$msg,
'data' =>$data
);
exit(json_encode($result));
}
2. To configure composer.json
Open the composer.json file , find "autoload" Configuration item , Add the following code :
"files":[
"app/Helper/functions.php"
]3. perform composer command
Open the terminal , Execute the following command
composer dump-autoload4. test
public function cqny(){
return success(' I only have a rose in my pocket , This trip is high and far away .');
return error(' I only have a rose in my pocket , This trip is high and far away .');
}

边栏推荐
- I was stunned by this question that I browsed 746000 times
- MQTT例程
- 用于校园流浪猫信息记录和分享的小程序源码/微信云开发中大猫谱小程序源码
- 代码随想录笔记_哈希_349两个数的交集
- Ten methods to prevent blackmail software from attacking data
- 全新UI四方聚合支付系统源码/新增USDT提现/最新更新安全升级修复XSS漏洞补单漏洞
- How to use RPA to achieve automatic customer acquisition?
- 别人的快乐
- 云开发打工人必备上班摸鱼划水微信小程序源码
- KBxxxxxx不一定是补丁,也可能是某个问题解决方案的描述
猜你喜欢

3d智能工厂工艺流转可视化交互展示应用优点

ECCV 2022 | airdet: a small sample target detection method without fine tuning

MQTT例程

网络基础概论

I was stunned by this question that I browsed 746000 times

OSPF实验

K210——声源定位、声音识别

Explain the four asynchronous solutions of JS in detail: callback function, promise, generator, async/await

Altium designer outputs Gerber and other production documents
![[quality] code quality evaluation standard](/img/33/2c2256fd98b908ddaf5573f644ad7f.png)
[quality] code quality evaluation standard
随机推荐
How to use RPA to achieve automatic customer acquisition?
工程经济学知识点总结
如何把thinkphp5的项目迁移到阿里云函数计算来应对流量洪峰?
ECCV 2022 | AirDet:无需微调的小样本目标检测方法
Polygon zkEVM——Hermez 2.0简介
where、having、group by、order by,is null,not in,子查询,delete,日期函数
深度剖析 —— 预处理
家庭亲戚关系计算器微信小程序源码
OSPF实验
云开发打工人必备上班摸鱼划水微信小程序源码
多年前的回忆
Others' happiness
多重继承与派生类成员标识
I want to talk about high concurrency.
Excel uses countif statistics
3D intelligent factory process flow visualization interactive display application advantages
Eight practical new functions of es2022
Explain the four asynchronous solutions of JS in detail: callback function, promise, generator, async/await
Only when you are far away will you miss
一款好看的iapp捐赠榜单源码