Heimo's blog


  • 首页

  • 分类

  • 标签

  • 归档

  • 搜索

Docker compose构建Gitlab Jira Confluence及破解

发表于 2020-09-22 | 分类于 Docker | 阅读次数

这次构建的compose是

  • gitlab:latest
  • jira:8.1.0
  • confluence:7.7.3
  • mysql:5.7
  • nginx:latest

生产部署考虑gitlab和mysql独立出去,不和atlassian家的这俩服务放一起。

gitlab也不使用这里的mysql服务,比较独立,很吃内存,mysql可以用rds云数据库。

接下来的工作只是构建和破解,用于测试,实际生产部署则按需修改。

我自己的docker的配置是给了i5的3个核心,8G内存,刚开始只给4G内存gitlab起不来。

实际没有其它容器的情况下docker吃掉了我15个G的内存,而且是编译完容器运行的时候,可能更多的是macos的内存使用机制导致的。

阅读全文 »

TP6的容器和依赖注入实践

发表于 2020-07-16 | 分类于 php | 阅读次数

TP6官方手册

创建两个类Foo和Bar,Foo中调用Bar中的函数

1
2
3
4
5
6
7
1
2
3
4
5
6
7
class Bar
{
    public function index(String $name){

        return 'Bar_'.$name;
    }
}
1
2
3
4
5
6
7
8
9

class Foo{

    public function index(String $name){
        $bar = new Bar();

        return 'Foo_'.$bar->index($name);
    }
}

依赖注入

构造函数注入
1
2
3
4
5
6
7
1
2
3
4
5
6
7
class Bar
{
    public function index(String $name){

        return 'Bar_'.$name;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Foo{
    
    protected $bar;

    //构造函数注入
    public function __construct(Bar $bar) {
        $this->bar = $bar;
    }


    public function index(String $name){
    
        return 'Foo_'.$this->bar->index($name);
    }
}
使用invoke助手函数
1
$bar = invoke('namespace\Bar');
操作方法注入
1
2
3
4
5
//假设Foo为Controller,index为操作方法
public function index(String $name, Bar $bar){
    
    return 'Foo_'.$bar->index($name);
}

先使用bind,再使用app助手函数调用容器

bind手动绑定类到容器中,支持多种绑定方式
  • 在服务类的register方法中进行绑定
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
declare (strict_types = 1);

namespace app;

use think\Service;

/**
 * 应用服务类
 */
class AppService extends Service
{
    public function register()
    {
        // 服务注册
        bind('bar', 'namespace\Bar');
    }

    public function boot()
    {
        // 服务启动
    }
}

  • 在app目录下面定义provider.php文件中进行批量绑定
1
2
3
4
5
6
7
8
9
10
11
12
<?php
use app\ExceptionHandle;
use app\Request;

// 容器Provider定义文件
return [
    'think\Request'          => Request::class,
    'think\exception\Handle' => ExceptionHandle::class,
    
    'bar'   => namespace\Bar::class,
];

app助手函数进行容器中的类解析调用,对于已经绑定的类标识,会自动快速实例化
1
$bar = app('bar');
对象化调用
1
app()->bar()->index($name);

转载使用注明出处。原文链接 https://heimo-he.github.io/php/2020/07/16/tp6-di-container/

阅读全文 »

MySQL Field 'xxxx' doesn’t have a default value

发表于 2019-04-17 | 分类于 mysql | 阅读次数

问题

1
SQLSTATE[HY000]: General error: 1364 Field 'xxxx' doesn't have a default value

原因

  • 1. 该字段为设置default value
  • 2. mysql配置开启了严格模式
阅读全文 »

通过docker compose编排的php7.1+mysql5.6+nginx+redis开发环境

发表于 2019-04-10 | 分类于 docker | 阅读次数

Github 地址

通过docker compose编排的php7.1+mysql5.6+nginx+redis开发环境; 使用docker hub官方镜像,方便修改php版本,部署快捷,并且可以有效的统一团队开发环境。

环境内容

  • php-fpm7.1
    • Debian镜像改为阿里云镜像
    • 编译好的docker hub镜像地址
  • mysql5.6
  • nginx
  • redis
阅读全文 »

那些年让你迷惑的阻塞、非阻塞、异步、同步

发表于 2018-11-27 | 分类于 php | 阅读次数

在IT圈混饭吃,不管你用什么编程语言、从事前端还是后端,阻塞、非阻塞、异步、同步这些概念,都需要清晰地掌握,否则,怎么与面试官谈笑风生(chui niu pi)?但是,掌握这些概念又不是非常容易,尤其对非科班出身的,更加困难。本文试图给出一个清晰简明但不失深刻的介绍,希望对大家有所帮助。

阅读全文 »

使用iperf测试VPS网速

发表于 2018-11-23 | 分类于 linux | 阅读次数

网速是一台 VPS 的关键指标之一,那么如何测试网速。下面介绍一款Linux 下专业测试网络速度的工具:iperf,适用于 Linux 机器对 Linux 机器。

  • 在vps上和本地Linux分别安装iperf

apt-get install iperf

阅读全文 »

Ubuntu 更新gcc

发表于 2018-11-01 | 分类于 linux | 阅读次数
  • 添加软件源

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

如果报错add-apt-repository command not found

sudo apt-get install python-software-properties

sudo apt-get install software-properties-common

sudo apt-get update

阅读全文 »

解决GitHub提交历史头像不显示问题

发表于 2018-11-01 | 分类于 git | 阅读次数
  • 在该项目下执行git config user.email,所显示的邮箱肯定不是github邮箱

  • 执行git config user.email "github邮箱",修改的是该项目的user email

  • 如果想修改所有的项目,可直接修改全局配置git config --global user.email "github邮箱"

阅读全文 »

MacOS command

发表于 2018-09-11 | 分类于 macos | 阅读次数
  • 关闭/开启rootless(System Integrity Protection),进入恢复模式(重启,长按command+R)

csrutil disablecsrutil enable

  • 在Finder标题栏显示完整路径

defaults write com.apple.finder.FXShowPosixPathInTitle -bool true

阅读全文 »

发布自己的composer包

发表于 2018-07-20 | 分类于 php | 阅读次数

创建github库

  • 编写composer.json(设置dev-master别名为1.0.x-dev)

  • 编写readme

  • 提交源码(只需要一个master分支足够)

  • 打tag(格式v1.0.0)

阅读全文 »
1 2 … 4
Heimo

Heimo

玫瑰即玫瑰,花香无意义

34 日志
11 分类
33 标签
RSS
Links
  • 小余和岁岁的个人博客
  • 嘿嘿的博客
© 2017 - 2020 Heimo
由 Jekyll 强力驱动
主题 - NexT.Mist