Mr.Blog


  • 首页

  • 归档

  • 标签

  • 分类

  • 搜索

Mac 配置

发表于 2021-07-13 | 分类于 Mac

开启/关闭允许安装 “任何来源” 的软件

1
2
3
4
# 开启
sudo spctl --master-disable
# 关闭
sudo spctl --master-enable

设置一位密码

1
2
pwpolicy -clearaccountpolicies
# 提示 Clearing global acount policies 则表示成功

访达文件自动排序

1
打开访达 - 工具栏 - 显示 - 查看显示选项 - 分组方式(无)、排序方式(种类)- 点击「用作默认」

Laravel Doctrine

发表于 2021-07-12 | 分类于 Laravel

Laravel8.x 安装 laravel-doctrine/orm

安装

1
2
3
4
5
6
# 降低相关包版本,以便安装 laravel-doctrine/orm
composer require doctrine/dbal:"^2.6"
composer require doctrine/inflector:"^1.4"
composer require laravel-doctrine/orm:"~1.7"
# 发布配置文件
php artisan vendor:publish --tag="config" --provider="LaravelDoctrine\ORM\DoctrineServiceProvider"

生成元数据和实休

1
2
3
4
5
6
7
8
9
10
# 生成元数据
php artisan doctrine:mapping:import --namespace=App\\Entities\\ xml database/mappings
# 配置 doctrine.php
'meta' => env('DOCTRINE_METADATA', 'xml'),
'paths' => [base_path('database/mappings')],
# 生成实体
php artisan doctrine:generate:entities / --generate-methods

# 需注意一点,如果 meta => env('DOCTRINE_METADATA', 'annotations'), 则生成实体时,命名必须包含 --generate-annotations
php artisan doctrine:generate:entities / --generate-methods --generate-annotations
阅读全文 »

Git 常用命令

发表于 2021-07-12 | 分类于 Git

删除 git branch -a 中不存在的远程分支

1
2
3
4
5
6
7
8
# 查看所有分支
git branch -a

# 查看本地分支对应的远程分支的状态
git remote show origin

# 删除没用的引用
git remote prune origin

标签命令

1
2
3
4
5
6
7
8
9
10
# 删除所有本地标签
git tag -d $(git tag -l)

# 获取远程所有标签
git fetch

# 删除所有远程标签
git push origin --delete $(git tag -l) # Pushing once should be faster than multiple times

# 若要删除所有远程标签,步骤如下:删除所有本地标签 -> 获取远程所有标签 -> 删除所有远程标签

导出变更文件

1
2
3
4
# 命令
git archive -o 导出路径/xxx.zip NewCommitId $(git diff --name-only OldCommitId NewCommitId)
# Example
git archive -o ~/Desktop/update/update.zip 71a5f092424ce9c0fedcc127e7a0879170a4c45a $(git diff --name-only b7e3d2c8cb1c98f8c9ea006971ce50ba5d97488b 71a5f092424ce9c0fedcc127e7a0879170a4c45a)

Linux 常用命令

发表于 2018-01-27 | 更新于: 2021-07-12 | 分类于 Linux

chmod

1
2
3
4
5
6
7
8
#修改web目录下所有文件夹与文件的权限
chmod -R 755 web
#修改web目录下的所有目录权限
find web -type d -exec chmod 755 {} \;
#修改web目录下的所有文件权限
find web -type f -exec chmod 644 {} \;
#批量清空web目录下所有文件内容
for i in `find web -type f`;do cat /dev/null > $i;done

chown

1
2
3
4
#修改文件或目录的所属组和所有者
chown -R 组:用户 路径
#修改web目录及子文件所属组和所有者
chown -R www:www web
阅读全文 »

Nginx 负载均衡

发表于 2021-07-12 | 分类于 Nginx

负载均衡SLB(Server Load Balancer)是一种对流量进行按需分发的服务,通过将流量分发到不同的后端服务来扩展应用系统的服务吞吐能力,并且可以消除系统中的单点故障,提升应用系统的可用性。
即将项目部署在多台服务器,通过 nginx 负载均衡策略转发请求至不同的服务器。

域名 项目路径 监听端口 配置文件
sev.test.com /data/project/test; 80 sev.test.com.conf
sev.test.com /data/project/test; 8001 sev.test.com.8001.conf
sev.test.com /data/project/test; 8002 sev.test.com.8002.conf
阅读全文 »

Laravel API 开发心得

发表于 2021-04-30 | 更新于: 2021-07-12 | 分类于 Laravel

前言

虽然开发了几年,但一直没有使用 Laravel 作为项目框架,在 Laravel 里,属于不折不扣的新人,正好新项目用了 Laravel,在这分享一下 Laravel 开发 API 心得,希望能给想使用 Laravel 开发的人带来帮助。

通过实现「用户注册」接口,来介绍每个功能的使用场景。
PS:「用户注册」接口纯粹是为了方便介绍,所以没有使用自带的 Auth 模块.

大纲

  • 开发环境
  • 项目搭建
  • 目录结构
  • 路由加载
  • API 规范
  • Enum 枚举
  • 表单场景验证
  • 事件监听
  • 用户注册
  • Eloquent 条件查询
  • 模型事件
  • 队列
  • Passport OAuth 认证
  • 资料
  • 补充点
  • 升级8.x
阅读全文 »

Supervisord 进程管理工具

发表于 2021-04-30 | 分类于 Other

Supervisord 进程管理工具

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 安装
yum install supervisor

# 加载自定义配置
vim /etc/supervisord.conf
[include]
files = supervisord.d/*.conf

# 新建 laravel.conf
vim /etc/supervisord.d/laravel.conf
[program:laravel]
process_name=%(program_name)s_%(process_num)02d
command=php /data/wwwroot/laravel.com/artisan queue:work --sleep=3
autostart=true
autorestart=true
user=www
numprocs=4
redirect_stderr=true
stdout_logfile=/data/supervisor/laravel.com/queue.log

# 新建 /data/supervisor/laravel.com 目录,并设置文件属组
mkdir -p /data/supervisor/laravel.com
chown -R www:www /data/supervisor

# 运行命令
supervisorctl reread
supervisorctl update
supervisorctl start laravel:*

# 问题
# supervisorctl reread - error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224
supervisord -c /etc/supervisord.conf

# Error: Another program is already listening on a port that one of our HTTP servers is configured to use.
# 第一种:
ps aux | grep supervisord
kill 进程号
# 第二种
supervisorctl
reread
update
start all
status
阅读全文 »
123…15
Mr

Mr

懒........

102 日志
21 分类
56 标签
RSS
Links
  • Novnan
  • 挨踢Blog
  • Eagle
  • Timber
  • 谢炳南
© 2020 — 2021 Mr
0%