编辑 config.inc.php
文件,使用 http 登录模式,只要浏览器不关闭就可以继续使用。
// 原来的 cookie 改为 http
$cfg['Servers'][$i]['auth_type'] = 'http';
编辑 config.inc.php
文件,使用 http 登录模式,只要浏览器不关闭就可以继续使用。
// 原来的 cookie 改为 http
$cfg['Servers'][$i]['auth_type'] = 'http';
因为新电脑不能直接安装 linux ,只能使用 vmware 内安装虚拟机。安装 vmware 扩展工具,才能使用图形加速,共享目录等功能。
apt install open-vm-tools
设置了 共享文件夹 后,每次开机后都要连接共享,如果要实现自动加载,在 /etc/fstab
中添加以下代码:
.host:/share_name /mnt/hgfs/access fuse.vmhgfs-fuse allow_other,uid=1000,gid=1000,auto_unmount,defaults 0 0
share_name 是主机共享出来的目录名,/mnt/hgfs/access 是虚拟机内的访问路径。
在 linux 中使用 yarn 安装组件时,出现以下错误:
Error: pngquant failed to build, make sure that libpng-dev is installed
安装 libpng-dev 组件就可以了:
sudo apt install libpng-dev
你可以在 Apache 上做各种各样的配置,但是主要的和最常见的配置将在下面做出解释。
默认情况下,Apache 设置为在机器启动时自动启动,因此你不必手动启用它。你可以使用以下命令检查它是否正在运行以及其他相关信息:
systemctl status apache2
check if apache is running
并且你可以检查你正在使用的版本:
apachectl -V
一种更简单的检查方法时访问服务器的 IP 地址,如果你得到默认的 Apache 页面,那么一切都正常。
首先复制 resources\lang\en 目录下边的 validation.php到新建的文件夹zh-cn中,用下面代码替换之前的代码,在 attributes
中设置字段,最后设置config下的app.php中修改 'locale' => 'zh-cn'
。
<?php
return [
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
| the validator class. Some of these rules have multiple versions such
| as the size rules. Feel free to tweak each of these messages here.
|
*/
'accepted' => ':attribute必须接受',
'active_url' => ':attribute必须是一个合法的 URL',
'after' => ':attribute 必须是 :date 之后的一个日期',
'after_or_equal' => ':attribute 必须是 :date 之后或相同的一个日期',
'alpha' => ':attribute只能包含字母',
'alpha_dash' => ':attribute只能包含字母、数字、中划线或下划线',
'alpha_num' => ':attribute只能包含字母和数字',
'array' => ':attribute必须是一个数组',
'before' => ':attribute 必须是 :date 之前的一个日期',
'before_or_equal' => ':attribute 必须是 :date 之前或相同的一个日期',
'between' => [
'numeric' => ':attribute 必须在 :min 到 :max 之间',
'file' => ':attribute 必须在 :min 到 :max KB 之间',
'string' => ':attribute 必须在 :min 到 :max 个字符之间',
'array' => ':attribute 必须在 :min 到 :max 项之间',
],
'boolean' => ':attribute 字符必须是 true 或 false',
'confirmed' => ':attribute 二次确认不匹配',
'date' => ':attribute 必须是一个合法的日期',
'date_format' => ':attribute 与给定的格式 :format 不符合',
'different' => ':attribute 必须不同于 :other',
'digits' => ':attribute必须是 :digits 位.',
'digits_between' => ':attribute 必须在 :min 和 :max 位之间',
'dimensions' => ':attribute具有无效的图片尺寸',
'distinct' => ':attribute字段具有重复值',
'email' => ':attribute必须是一个合法的电子邮件地址',
'exists' => '选定的 :attribute 是无效的.',
'file' => ':attribute必须是一个文件',
'filled' => ':attribute的字段是必填的',
'image' => ':attribute必须是 jpeg, png, bmp 或者 gif 格式的图片',
'in' => '选定的 :attribute 是无效的',
'in_array' => ':attribute 字段不存在于 :other',
'integer' => ':attribute 必须是个整数',
'ip' => ':attribute必须是一个合法的 IP 地址。',
'json' => ':attribute必须是一个合法的 JSON 字符串',
'max' => [
'numeric' => ':attribute 的最大长度为 :max 位',
'file' => ':attribute 的最大为 :max',
'string' => ':attribute 的最大长度为 :max 字符',
'array' => ':attribute 的最大个数为 :max 个.',
],
'mimes' => ':attribute 的文件类型必须是 :values',
'min' => [
'numeric' => ':attribute 的最小长度为 :min 位',
'file' => ':attribute 大小至少为 :min KB',
'string' => ':attribute 的最小长度为 :min 字符',
'array' => ':attribute 至少有 :min 项',
],
'not_in' => '选定的 :attribute 是无效的',
'numeric' => ':attribute 必须是数字',
'present' => ':attribute 字段必须存在',
'regex' => ':attribute 格式是无效的',
'required' => ':attribute 字段是必须的',
'required_if' => ':attribute 字段是必须的当 :other 是 :value',
'required_unless' => ':attribute 字段是必须的,除非 :other 是在 :values 中',
'required_with' => ':attribute 字段是必须的当 :values 是存在的',
'required_with_all' => ':attribute 字段是必须的当 :values 是存在的',
'required_without' => ':attribute 字段是必须的当 :values 是不存在的',
'required_without_all' => ':attribute 字段是必须的当 没有一个 :values 是存在的',
'same' => ':attribute和:other必须匹配',
'size' => [
'numeric' => ':attribute 必须是 :size 位',
'file' => ':attribute 必须是 :size KB',
'string' => ':attribute 必须是 :size 个字符',
'array' => ':attribute 必须包括 :size 项',
],
'string' => ':attribute 必须是一个字符串',
'timezone' => ':attribute 必须是个有效的时区.',
'unique' => ':attribute 已存在',
'url' => ':attribute 无效的格式',
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute.rule" to name the lines. This makes it quick to
| specify a specific custom language line for a given attribute rule.
|
*/
'custom' => [
'attribute-name' => [
'rule-name' => 'custom-message',
],
],
/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/
'attributes' => [
'username' => '帐号',
'pwd' => '密码',
'phone' => '手机',
],
];
方法一
JSON.stringify(arr) === '[]'
arr.length === 0
+arr === 0
上面三种判断数组为空的方法虽然大多数情况下都可以用,但依然存在bug,比如令 arr[-1] = ''
时,数组不为空,但三者都返回true,所以如果业务代码中一旦遇到这种bug,就需要来个函数了:
var arr = []
arr[-1] = ''
function isEmptyObject(e) {
var t;
for (t in e)
return false;
return true;
}
isEmptyObject(arr);
首先到 官网下载 运行文件,但是官方提示需要 unixODBC
,安装方法:
sudo apt install unixodbc
再次运行,发现缺少运行库 libstdc++.so.5
,安装方法:
sudo apt install libstdc++5
再次运行,OK!
// 合并输入,如果有相同的key,用户输入的值会被替换掉,否则追加到 input
$request->merge(['foo' => 'bar', ....]);
// 替换所有输入
$request->replace([..])
// 设置某参数,如果存在则替换,否则新增
$request['foo'] = 'bar';
// 移除某参数
unset($request['foo'])
使用 request 注入验证时,获取路由中的参数:
// 获取当前需要排除的id,这里的 user 是 路由 {} 中的参数
$id = $this->route('user');
字段唯一性同时排除指定ID验证:
// unique:表名,字段,需要排除的ID
'user' => 'required|unique:users,user,' . $id
匹配字段验证(如输入两次密码是否一致):
'password' => 'required|min:8|confirmed',
'password_confirmation' => 'required' // 可选验证规则,但名称一定要使用 +_confirmation 方式命名
在使用 ssh 或 scp 时,通常使用 ssh -p 22 -i /path/to/pem user@hostname
,如果主机名太长,或是 pem 文件太深,输入时很不方便,其实可以配置别名来简化输入。
编辑或创建文件 ~/.ssh/config
,输入以下内容:
Host server
User user
HostName ipaddress_or_hostname
IdentityFile /path/to/pem
port 22
不需要的参数(例如 IdentityFile)可以不写,允许添加多个别名配置
使用方法:
# 登录到服务器
ssh server
# 复制文件
scp ~/file server:~/