企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ 助手函数路径 \vendor\laravel\framework\src\Illuminate\Support\helpers.php config('app.cdn_domain') 读取配置 env('CDN_DOMAIN') 只在配置文件使用的读取 $path = app_path(); 返回app路径C:\www\laravel\app, $path = base_path(); 项目根目录,C:\www\laravel $path = config_path();配置路径C:\www\laravel\config $path = public_path(); 返回public路径C:\www\laravel\public,路径函数都支持生成文件路径 $path = resource_path('assets/sass/app.scss'); 资源路径;C:\www\laravel\resources\assets/sass/app.scss $path = storage_path('app/file.txt');文件存储路径C:\www\laravel\storage\app/file.txt __("lang.test") //本地化,lang是文件,配置'locale' => 'zh-CN' trans("lang.test")只翻译键 e('<html>foo</html>') 输出源代码 str_contains('This is my name', 'my'); 是否包含某个值 str_limit('我是中国人', 3, '...') 截取字符串 中文3个一个汉字 str_random(40) 随机字符串 asset('img/photo.jpg') 生成完整包含http/https路径 secure_asset()只生成https url('user/profile', ['id'=>1])http://laravel.api.shanliwawa.top/user/profile/1 secure_url只生成https url()->full() 当前完整域名 $cookie = cookie('name', 'value', $minutes); {{ csrf_field() }} 生成令牌 $token = csrf_token(); 获取令牌 encrypt() decrypt() 加密解密 dump()打印变量 dd() 打印后停止 info('Some helpful information!'); 写入日志 logger('Debug message'); 错误写入日志 redirect('/home'); 跳转 $value = session('key'); session(['chairs' => 7, 'instruments' => 3]); 获取设置session use Illuminate\Support\Facades\Hash; Hash::make($request->newPassword) 加密密码 助手加密解密函数,支持字符串数组对象 encrypt() decrypt() use Illuminate\Support\Facades\Crypt;无序列化加密 $encrypted = Crypt::encryptString('Hello world.'); $decrypted = Crypt::decryptString($encrypted); Crypt::encrypt() 支持字符串数组对象 Crypt::decrypt() use Illuminate\Http\Request 是请求对象数据处理 $request->input('title'); 获取输入 $site = $request->input('site', 'Laravel学院'); 请求为空取后边值 $request->input('books.0.author') 数组获取单值 $request->json(); 返回JSON数据格式 $request->all(); 全部 $request->except('id');排除 $request->only(['name', 'site', 'domain']); 只获取这些字段 $request->has('id') 判断id字段是否存在 ~~~