当前位置:网站首页>Laravel adds custom helper functions
Laravel adds custom helper functions
2022-04-23 11:23:00 【Fields after dusk】
Laravel Add custom helper function
First, prepare one laravel Framework
At the root app New under folder helpers.php file .
Open the root directory composer.json file , stay autoload add "files":[“app/helpers.php”]
Go to the command line , Enter current project , perform composer dumpautoload command .
Let's start with one error and success Of json encapsulation
/** * Format error message * @param string $message * @param int $code * @return array */
function error($message = '', $code = 400)
{
return ['status' => 0, 'code' => $code, 'message' => $message, 'data' => ''];
}
/** * Formatting information * @param string $message * @param int $code * @return array */
function success($message = '', $code = 200)
{
return ['status' => 1, 'code' => $code, 'message' => $message, 'data' => ''];
}
There's a second way ( Use the framework to guide the loading itself )
stay bootstrap/app.php add
require __DIR__ . '/../app/helpers.php';
版权声明
本文为[Fields after dusk]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231119486104.html
边栏推荐
- Oracle连通性测试小工具
- MySQL failed to insert the datetime type field without single quotation marks
- 分享两个实用的shell脚本
- oh-my-lotto
- CUMCM 2021-B:乙醇偶合制备C4烯烃(2)
- 讯飞2021年营收183亿:同比增41% 净利为15.56亿
- Laravel绑定钉钉群警报(php)
- PDMS soft lithography process
- 学习 Go 语言 0x03:理解变量之间的依赖以及初始化顺序
- Implementation of partition table of existing data table by MySQL
猜你喜欢
GPU, CUDA,cuDNN三者的關系總結
nacos基础(8):登录管理
赛微微电科创板上市破发:跌幅达26% 公司市值44亿
年度最尴尬的社死瞬间,是Siri给的
MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
Write console script by laravel
实践数据湖iceberg 第三十课 mysql->iceberg,不同客户端有时区问题
MIT:用无监督为世界上每个像素都打上标签!人类:再也不用为1小时视频花800个小时了
nacos基础(6):nacos配置管理模型
随机推荐
赛微微电科创板上市破发:跌幅达26% 公司市值44亿
Learning go language 0x08: practice using error in go language journey
Mysql排序的特性详情
ConstraintLayout布局
Who said you should know PS? This open-source artifact can also be pulled in batch, and the effect is outstanding!
Learn go language 0x04: Code of exercises sliced in go language journey
Jupyter lab top ten high productivity plug-ins
解读机器人创造出来的艺术
mysql创建存储过程及函数详解
Get things technology network optimization - CDN resource request Optimization Practice
MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
实践数据湖iceberg 第三十课 mysql->iceberg,不同客户端有时区问题
Laravel admin time range selector daterange default value problem
CUMCM 2021-b: preparation of C4 olefins by ethanol coupling (2)
26. Delete duplicates in ordered array
MySQL数据库事务transaction示例讲解教程
进程间通信 -- 消息队列
Implementation of inserting millions of data into MySQL database in 10 seconds
活动进行时! 点击链接加入直播间参与“AI真的能节能吗?”的讨论吧!
Difference between pregnancy box and delivery box