当前位置:网站首页>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
边栏推荐
猜你喜欢
RebbitMQ的初步了解
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
Learn go language 0x04: Code of exercises sliced in go language journey
More reliable model art than deep learning
解读机器人编程课程的生物认知度
Summary of the relationship among GPU, CUDA and cudnn
C#的学习笔记【八】SQL【一】
解读机器人创造出来的艺术
VM set up static virtual machine
随机推荐
When the activity is in progress! Click the link to join the live studio to participate in "can AI really save energy?" Let's have a discussion!
MySQL索引优化之分页探索详细介绍
学习 Go 语言 0x06:《Go 语言之旅》中 斐波纳契闭包 练习题代码
QT 怎么把QWigdet变成QDialog
How does QT turn qwigdet into qdialog
QT信号量 无法解析的错误的总结
Detailed introduction to paging exploration of MySQL index optimization
MySQL分区表实现按月份归类
PDMS软光刻加工过程
Common parameters of ffmpeg command line
PyTorch 神经网络训练器
ConstraintLayout布局
Applet payment
Mysql中一千万条数据怎么快速查询
Three web components (servlet, filter, listener)
Usage record of map < qstring, bool >
微型机器人的认知和研发技术
Understanding of fileprovider path configuration strategy
nacos基础(6):nacos配置管理模型
Implementation of partition table of existing data table by MySQL