本文转自laravel-china
依赖注入
1 | <?php |
IoC 容器类
1 | //写一个简单的 IoC 容器类 |
魔术方法
1 | //https://laravel-china.org/articles/20625 |
控制反转
1 | class Boos{ |
依赖注入原理
1 | <?php |
反射机制实现依赖注入
1 | <?php |
IOC
1 | <?php |
依赖注入 控制反转
1 | interface DbConnect { |
IOC demo
1 |
|
本文转自laravel-china
1 | <?php |
1 | //写一个简单的 IoC 容器类 |
1 | //https://laravel-china.org/articles/20625 |
1 | class Boos{ |
1 | <?php |
1 | <?php |
1 | <?php |
1 | interface DbConnect { |
1 |
|
通常我们可以使用github pages 来搭建静态博客,建立一个username.github.io的项目就可以了,如果要将其他项目也作为页面展示,可以将代码推送到gh-pages分支。
GitHub pages木有默认样式,所以如果你不会自己写css,博客很难看的,所以有了hexo.
先安装好git node hexo
1 | $ hexo init blog |
1 | 1.生成指定名字的密钥 |
1 | deploy: |
1 | $ hexo clean && hexo g |
登录admin 即可看到我们所有的文章内容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
44
45λ npm i hexo-admin --save
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated connect@2.7.11: connect 2.x series is deprecated
npm WARN deprecated cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ hexo-admin@2.3.0
added 251 packages in 23.975s
╭─────────────────────────────────────╮
│ │
│ Update available 5.6.0 → 6.4.1 │
│ Run npm i npm to update │
│ │
╰─────────────────────────────────────╯
#网站底部字数统计
d:\code\hexo\blog
λ npm install hexo-wordcount --save
npm WARN rollback Rolling back node-pre-gyp@0.10.0 failed (this is probably harmless): EPERM: operation not permitted, scandir 'd:\code\hexo\blog\node_modules\fsevents\node_modules'
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ hexo-wordcount@6.0.1
added 1 package in 10.289s
搜索npm install hexo-generator-searchdb --save
npm install hexo-generator-search --save
在根目录下的/theme/next/_config.yml文件中添加配置:
search:
path: search.xml
field: post
format: html
limit: 10000
在根目录下的/theme/next/_config.yml文件中搜索local_search,将enable改为true:
local_search:
enable: true
中文乱码
将config.yml 和md文件编码转为utf-8
修改config.yml language: zh-Hans
1 | $ hexo new "PHP依赖注入" |
Hexo 默认以标题做为文件名称,但您可编辑_config.yml new_post_name
参数来改变默认的文件名称,举例来说,设为 :year-:month-:day-:title.md 可让您更方便的通过日期来管理文章。
1 | 主菜单设置 blog/_config.yml 添加如下配置 |
1 | npm install hexo-wordcount --save |
1 | vi D:\blog\themes\hexo-theme-next\layout_partials\ footer.swig |
1 | 将themes/next/(我用的是NexT主题)中的.git/删除,否则无法将主题文件夹push; |
用GitHub登录 https://gitter.im1
2
3
4
5
6
7
8
9
10
11
12
13
14vi next/layout/_third-party/gitter.swig
<script>
((window.gitter = {}).chat = {}).options = {
//room替换成自己的聊天室名称即可,room的名称规则是:username/roomname
//http://www.xetlab.com/2019/04/14/%E7%BB%99%E5%9F%BA%E4%BA%8EHEXO%E7%9A%84%E5%8D%9A%E5%AE%A2%E6%B7%BB%E5%8A%A0gitter%E5%9C%A8%E7%BA%BF%E4%BA%A4%E6%B5%81/
room: 'sushengbuhuo/chat'
};
</script>
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
vi next/layout/layout/_layout.swig
{% include '_third-party/gitter.swig' %}
1 | https://www.njphper.com/posts/a4cd94b2.html |
1 | https://github.com/coneycode/hexo-git-backup |
1 | 打开/themes/next/layout/_partials/head.swig文件,添加一行代码:<meta name="referrer" content="no-referrer" />,具体如下所示: |
1 | 新建hexo分支 |
1 | $ git init //git初始化 |
1 | <meta name="referrer" content="never" /> |
1 | 打开themes->next->layout->_partials->head.swig文件,在以下位置插入这样一段代码: |
1 | 创建项目 https://gitee.com/sushengbuhuo/sushengbuhuo 注意和GitHub不一样,项目名不是sushengbuhuo.gitee.io |
打造个性超赞博客Hexo+NexT+GitHubPages的超深度优化