├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── THINKPHP-LICENSE
├── application
├── .htaccess
├── behavior
│ ├── GodPolicy.php
│ └── UserPolicy.php
├── command.php
├── common.php
├── http
│ └── middleware
│ │ ├── Auth.php
│ │ ├── GodAuthorize.php
│ │ └── UserAuthorize.php
├── provider.php
├── tags.php
├── user
│ ├── controller
│ │ ├── Auth.php
│ │ ├── Post.php
│ │ └── Session.php
│ ├── model
│ │ ├── Post.php
│ │ └── User.php
│ └── validate
│ │ ├── Auth.php
│ │ ├── Session.php
│ │ └── UpdateUser.php
└── welcome
│ └── controller
│ └── Index.php
├── build.php
├── composer.json
├── composer.lock
├── config
├── app.php
├── cache.php
├── console.php
├── cookie.php
├── database.php
├── log.php
├── middleware.php
├── session.php
├── template.php
└── trace.php
├── database
├── migrations
│ ├── 20180614013134_users.php
│ └── 20190728094237_posts.php
└── seeds
│ ├── Posts.php
│ └── Users.php
├── extend
└── .gitignore
├── public
├── .htaccess
├── favicon.ico
├── index.php
├── robots.txt
├── router.php
└── static
│ └── .gitignore
├── resources
└── views
│ ├── _layout
│ ├── default.blade.php
│ ├── footer.blade.php
│ └── header.blade.php
│ ├── user
│ ├── auth
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── index.blade.php
│ │ └── read.blade.php
│ └── session
│ │ └── create.blade.php
│ └── welcome
│ └── index
│ ├── about.blade.php
│ ├── help.blade.php
│ └── home.blade.php
├── route
└── route.php
├── runtime
└── .gitignore
└── think
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | /.vscode
3 | /vendor
4 | *.log
5 | thinkphp
6 | .env
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 |
3 | language: php
4 |
5 | branches:
6 | only:
7 | - stable
8 |
9 | cache:
10 | directories:
11 | - $HOME/.composer/cache
12 |
13 | before_install:
14 | - composer self-update
15 |
16 | install:
17 | - composer install --no-dev --no-interaction --ignore-platform-reqs
18 | - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
19 | - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
20 | - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
21 | - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
22 | - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
23 | - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
24 | - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
25 | - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
26 | - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
27 | - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
28 | - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
29 |
30 | script:
31 | - php think unit
32 |
33 | deploy:
34 | provider: releases
35 | api_key:
36 | secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
37 | file:
38 | - ThinkPHP_Core.zip
39 | - ThinkPHP_Full.zip
40 | skip_cleanup: true
41 | on:
42 | tags: true
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2019 AGD
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 介绍
2 |
3 | 本书将教你使用现代工具流构建一个类似微博的应用。
4 |
5 | 通过本书,你将会学到如 HTML、CSS、JavaScript、PHP、ThinkPHP 等 Web 开发的相关基础知识。
6 |
7 | 除此之外,编辑器使用、开发环境搭建、Git、Composer、Bootstrap 前端框架在本书中也会使用, 本书代码严格 PSR 规范编写,使用这些知识将会为你以后的 Web 开发生涯奠定结实的基础,无论在大型项目或是个人练手作品都能有一个好的开发习惯和规范。
8 |
9 | ## CDN
10 |
11 | 海外朋友可访问 https://learn.epicdata.net/thinkphp5-1-web-actual-combat/ 进行阅读
12 |
13 | ## 版本
14 |
15 | 这是 ThinkPHP 5.1 教程 - Web 入门开发实战 源码内容
16 |
17 | ## 安全提示
18 |
19 | PHP 5.6 及 PHP 7.0 在 2019-01-01 将正式停止维护,请开发时不要使用老版本的 PHP.
20 | 在 thinkphp 5.x/5.1.x 12 月 9 日之前的版本,存在安全漏洞.
21 | 请运行命令 composer update 将 ThinkPHP 框架更新至最新版本.
22 |
23 | ## 赞助项目
24 |
25 | ThinkPHP 5.1 教程 - Web 入门开发实战 是一个为了解决大多数新手开发者入门难,编写不规范等问题的入门教程书籍, 由 EpicLearn 发起. 如果您有兴趣支持此项目,请考虑成为赞助人.
26 |
27 | ## 感谢
28 |
29 | 文档样式基于 Markdown.Lite: https://www.kancloud.cn/epiclearn/markdown 进行构建
30 |
31 | ## 社区支持
32 |
33 | 在 [EpicLearn QQ 群](https://jq.qq.com/?_wv=1027&k=5T19zAw) 进行讨论反馈
34 |
35 | ## 贡献
36 |
37 | 本书内容托管地址: [ThinkPHP5.1-Web-Actual-combat](https://github.com/EpicLearn/ThinkPHP5.1-Web-Actual-combat)
38 |
39 | 本书源码托管地址: [ThinkPHP5.1-Web-Actual-combat-code](https://github.com/EpicLearn/ThinkPHP5.1-Web-Actual-combat-code)
40 |
41 | ## License
42 |
43 |
本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可。
--------------------------------------------------------------------------------
/THINKPHP-LICENSE:
--------------------------------------------------------------------------------
1 |
2 | ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
3 | 版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
4 | All rights reserved。
5 | ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
6 |
7 | Apache Licence是著名的非盈利开源组织Apache采用的协议。
8 | 该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
9 | 允许代码修改,再作为开源或商业软件发布。需要满足
10 | 的条件:
11 | 1. 需要给代码的用户一份Apache Licence ;
12 | 2. 如果你修改了代码,需要在被修改的文件中说明;
13 | 3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
14 | 带有原来代码中的协议,商标,专利声明和其他原来作者规
15 | 定需要包含的说明;
16 | 4. 如果再发布的产品中包含一个Notice文件,则在Notice文
17 | 件中需要带有本协议内容。你可以在Notice中增加自己的
18 | 许可,但不可以表现为对Apache Licence构成更改。
19 | 具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | POSSIBILITY OF SUCH DAMAGE.
33 |
--------------------------------------------------------------------------------
/application/.htaccess:
--------------------------------------------------------------------------------
1 | deny from all
--------------------------------------------------------------------------------
/application/behavior/GodPolicy.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | return [];
13 |
--------------------------------------------------------------------------------
/application/common.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // 应用公共文件
13 |
--------------------------------------------------------------------------------
/application/http/middleware/Auth.php:
--------------------------------------------------------------------------------
1 | with('validate', '请先登录');
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/application/http/middleware/GodAuthorize.php:
--------------------------------------------------------------------------------
1 | with('validate', '非法操作');
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/application/http/middleware/UserAuthorize.php:
--------------------------------------------------------------------------------
1 | id);
18 | return
19 | $result
20 | ? $next($request)
21 | : $this->redirect();
22 | }
23 |
24 | private function redirect()
25 | {
26 | return redirect('user/session/create')->with('validate', '非法操作');
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/application/provider.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // 应用容器绑定定义
13 | return [
14 | ];
15 |
--------------------------------------------------------------------------------
/application/tags.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // 应用行为扩展定义文件
13 | return [
14 | // 应用初始化
15 | 'app_init' => [],
16 | // 应用开始
17 | 'app_begin' => [],
18 | // 模块初始化
19 | 'module_init' => [],
20 | // 操作开始执行
21 | 'action_begin' => [],
22 | // 视图内容过滤
23 | 'view_filter' => [],
24 | // 日志写入
25 | 'log_write' => [],
26 | // 应用结束
27 | 'app_end' => [],
28 | ];
29 |
--------------------------------------------------------------------------------
/application/user/controller/Auth.php:
--------------------------------------------------------------------------------
1 | [
15 | 'except' => [
16 | 'create',
17 | 'save',
18 | 'index',
19 | 'read'
20 | ]
21 | ],
22 | 'GodAuthorize' => [
23 | 'only' => [
24 | 'delete'
25 | ]
26 | ]
27 | ];
28 |
29 | /**
30 | * 显示资源列表
31 | *
32 | * @return \think\Response
33 | */
34 | public function index()
35 | {
36 | $this->assign([
37 | 'users' => User::paginate(10),
38 | 'god' => Hook::exec('app\\behavior\\GodPolicy')
39 | ]);
40 | return $this->fetch();
41 | }
42 |
43 | /**
44 | * 显示创建资源表单页.
45 | *
46 | * @return \think\Response
47 | */
48 | public function create()
49 | {
50 | return $this->fetch();
51 | }
52 |
53 | /**
54 | * 保存新建的资源
55 | *
56 | * @param \think\Request $request
57 | * @return \think\Response
58 | */
59 | public function save(Request $request)
60 | {
61 | $requestData = $request->post();
62 | $result = $this->validate($requestData, 'app\user\validate\Auth');
63 | if (true !== $result) {
64 | return redirect('user/auth/create')->with('validate', $result);
65 | } else {
66 | $user = User::create($requestData);
67 | Session::set('user', $user);
68 | return redirect('user/auth/read')->params(['id' => $user->id]);
69 | }
70 | }
71 |
72 | /**
73 | * 显示指定的资源
74 | *
75 | * @param int $id
76 | * @return \think\Response
77 | */
78 | public function read($id)
79 | {
80 | $user = User::with(['posts' => function ($query) {
81 | $query->limit(8);
82 | $query->order('created_at', 'desc');
83 | }])->find($id);
84 | $this->assign([
85 | 'user' => $user,
86 | 'session' => Session::get('user')
87 | ]);
88 | return $this->fetch();
89 | }
90 |
91 | /**
92 | * 显示编辑资源表单页.
93 | *
94 | * @param int $id
95 | * @return \think\Response
96 | */
97 | public function edit($id)
98 | {
99 | $user = User::find($id);
100 | $this->assign([
101 | 'user' => $user,
102 | ]);
103 | return $this->fetch();
104 | }
105 |
106 | /**
107 | * 保存更新的资源
108 | *
109 | * @param \think\Request $request
110 | * @param int $id
111 | * @return \think\Response
112 | */
113 | public function update(Request $request, $id)
114 | {
115 | $requestData = $request->put();
116 | $result = $this->validate($requestData, 'app\user\validate\UpdateUser');
117 |
118 | if (true !== $result) {
119 | return redirect('user/auth/edit', ['id' => $id])->with('validate', $result);
120 | } else {
121 | $name = $requestData['name'];
122 | User::where('id', $id)->update(['name' => $name]);
123 | Session::set('user.name', $name);
124 | return redirect('user/auth/edit', ['id' => $id])->with('validate', '修改成功');
125 | }
126 | }
127 |
128 | /**
129 | * 删除指定资源
130 | *
131 | * @param int $id
132 | * @return \think\Response
133 | */
134 | public function delete($id)
135 | {
136 | User::where('id', $id)->where('god', false)->delete();
137 | return redirect('user/auth/index');
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/application/user/controller/Post.php:
--------------------------------------------------------------------------------
1 | [
13 | 'only' => [
14 | 'save',
15 | ]
16 | ]
17 | ];
18 |
19 | public function save(Request $request)
20 | {
21 | PostModel::create([
22 | 'content' => $request->content,
23 | 'user_id' => session('user.id')
24 | ]);
25 | return redirect('/');
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/application/user/controller/Session.php:
--------------------------------------------------------------------------------
1 | [
14 | 'except' => [
15 | 'create',
16 | 'save'
17 | ]
18 | ],
19 | ];
20 |
21 | /**
22 | * 显示资源列表
23 | *
24 | * @return \think\Response
25 | */
26 | public function index()
27 | {
28 | //
29 | }
30 |
31 | /**
32 | * 显示创建资源表单页.
33 | *
34 | * @return \think\Response
35 | */
36 | public function create()
37 | {
38 | return $this->fetch();
39 | }
40 |
41 | /**
42 | * 保存新建的资源
43 | *
44 | * @param \think\Request $request
45 | * @return \think\Response
46 | */
47 | public function save(Request $request)
48 | {
49 | $result = $this->validate($request->post(), 'app\user\validate\Session');
50 | if (true !== $result) {
51 | return redirect('user/session/create')->with('validate', $result);
52 | } else {
53 | $user = User::where('email', $request->email)->find();
54 | if ($user !== null && password_verify($request->password, $user->password)) {
55 | SessionFacade::set('user', $user);
56 | return redirect('user/auth/read')->params(['id' => $user->id]);
57 | } else {
58 | return redirect('user/session/create')->with('validate', '邮件地址不存在或密码错误');
59 | }
60 | }
61 | }
62 |
63 | /**
64 | * 显示指定的资源
65 | *
66 | * @param int $id
67 | * @return \think\Response
68 | */
69 | public function read($id)
70 | {
71 | //
72 | }
73 |
74 | /**
75 | * 显示编辑资源表单页.
76 | *
77 | * @param int $id
78 | * @return \think\Response
79 | */
80 | public function edit($id)
81 | {
82 | //
83 | }
84 |
85 | /**
86 | * 保存更新的资源
87 | *
88 | * @param \think\Request $request
89 | * @param int $id
90 | * @return \think\Response
91 | */
92 | public function update(Request $request, $id)
93 | {
94 | //
95 | }
96 |
97 | /**
98 | * 删除指定资源
99 | *
100 | * @param int $id
101 | * @return \think\Response
102 | */
103 | public function delete($id)
104 | {
105 | session('user', null);
106 | return redirect('user/session/create')->with('validate', '您已退出');
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/application/user/model/Post.php:
--------------------------------------------------------------------------------
1 | belongsTo('User');
13 | }
14 |
15 | // 定义数据表名
16 | protected $table = 'posts';
17 |
18 | // 定义时间戳字段名
19 | protected $createTime = 'created_at';
20 | protected $updateTime = 'updated_at';
21 | }
22 |
--------------------------------------------------------------------------------
/application/user/model/User.php:
--------------------------------------------------------------------------------
1 | hasMany('Post', 'user_id');
13 | }
14 |
15 | // 定义运行操作的字段
16 | protected $field = ['name', 'email', 'password', 'avatar'];
17 |
18 | // 定义数据表名
19 | protected $table = 'users';
20 |
21 | // 定义时间戳字段名
22 | protected $createTime = 'created_at';
23 | protected $updateTime = 'updated_at';
24 |
25 | // 设置修改器
26 | public function setPasswordAttr($value)
27 | {
28 | return password_hash($value, PASSWORD_DEFAULT);
29 | }
30 |
31 | public function setEmailAttr($value)
32 | {
33 | return strtolower($value);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/application/user/validate/Auth.php:
--------------------------------------------------------------------------------
1 | ['规则1','规则2'...]
12 | *
13 | * @var array
14 | */
15 | protected $rule = [
16 | '__token__' => 'token',
17 | 'name|名字' => 'require|max:50',
18 | 'email|邮件' => 'require|email|unique:users|max:255',
19 | 'password|密码' => 'require|confirm|min:6'
20 | ];
21 |
22 | /**
23 | * 定义错误信息
24 | * 格式:'字段名.规则名' => '错误信息'
25 | *
26 | * @var array
27 | */
28 | protected $message = [];
29 | }
30 |
--------------------------------------------------------------------------------
/application/user/validate/Session.php:
--------------------------------------------------------------------------------
1 | ['规则1','规则2'...]
12 | *
13 | * @var array
14 | */
15 | protected $rule = [
16 | '__token__' => 'token',
17 | 'email|邮件' => 'require|email|max:255',
18 | 'password|密码' => 'require|min:6'
19 | ];
20 |
21 | /**
22 | * 定义错误信息
23 | * 格式:'字段名.规则名' => '错误信息'
24 | *
25 | * @var array
26 | */
27 | protected $message = [];
28 | }
29 |
--------------------------------------------------------------------------------
/application/user/validate/UpdateUser.php:
--------------------------------------------------------------------------------
1 | ['规则1','规则2'...]
12 | *
13 | * @var array
14 | */
15 | protected $rule = [
16 | '__token__' => 'token',
17 | 'name|名字' => 'require|max:50',
18 | ];
19 |
20 | /**
21 | * 定义错误信息
22 | * 格式:'字段名.规则名' => '错误信息'
23 | *
24 | * @var array
25 | */
26 | protected $message = [];
27 | }
28 |
--------------------------------------------------------------------------------
/application/welcome/controller/Index.php:
--------------------------------------------------------------------------------
1 | assign([
13 | 'posts' => Post::with('user')->order('created_at', 'desc')->paginate(20)
14 | ]);
15 | return $this->fetch();
16 | }
17 |
18 | public function help()
19 | {
20 | return view();
21 | }
22 |
23 | public function about()
24 | {
25 | return view();
26 | }
27 | }
--------------------------------------------------------------------------------
/build.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | return [
13 | // 生成应用公共文件
14 | '__file__' => ['common.php'],
15 |
16 | // 定义demo模块的自动生成 (按照实际定义的文件名生成)
17 | 'demo' => [
18 | '__file__' => ['common.php'],
19 | '__dir__' => ['behavior', 'controller', 'model', 'view'],
20 | 'controller' => ['Index', 'Test', 'UserType'],
21 | 'model' => ['User', 'UserType'],
22 | 'view' => ['index/index'],
23 | ],
24 |
25 | // 其他更多的模块定义
26 | ];
27 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "topthink/think",
3 | "description": "the new thinkphp framework",
4 | "type": "project",
5 | "keywords": [
6 | "framework",
7 | "thinkphp",
8 | "ORM"
9 | ],
10 | "homepage": "http://thinkphp.cn/",
11 | "license": "Apache-2.0",
12 | "authors": [
13 | {
14 | "name": "liu21st",
15 | "email": "liu21st@gmail.com"
16 | }
17 | ],
18 | "require": {
19 | "php": ">=5.6.0",
20 | "topthink/framework": "5.1.*",
21 | "luoyy/think-blade": "^3.0",
22 | "topthink/think-migration": "^2.0",
23 | "fzaninotto/faker": "^1.8"
24 | },
25 | "autoload": {
26 | "psr-4": {
27 | "app\\": "application"
28 | }
29 | },
30 | "extra": {
31 | "think-path": "thinkphp"
32 | },
33 | "config": {
34 | "preferred-install": "dist"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "82abec14aedaff1afc32d3ba06f06c1d",
8 | "packages": [
9 | {
10 | "name": "fzaninotto/faker",
11 | "version": "v1.8.0",
12 | "source": {
13 | "type": "git",
14 | "url": "https://github.com/fzaninotto/Faker.git",
15 | "reference": "f72816b43e74063c8b10357394b6bba8cb1c10de"
16 | },
17 | "dist": {
18 | "type": "zip",
19 | "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/f72816b43e74063c8b10357394b6bba8cb1c10de",
20 | "reference": "f72816b43e74063c8b10357394b6bba8cb1c10de",
21 | "shasum": "",
22 | "mirrors": [
23 | {
24 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
25 | "preferred": true
26 | }
27 | ]
28 | },
29 | "require": {
30 | "php": "^5.3.3 || ^7.0"
31 | },
32 | "require-dev": {
33 | "ext-intl": "*",
34 | "phpunit/phpunit": "^4.8.35 || ^5.7",
35 | "squizlabs/php_codesniffer": "^1.5"
36 | },
37 | "type": "library",
38 | "extra": {
39 | "branch-alias": {
40 | "dev-master": "1.8-dev"
41 | }
42 | },
43 | "autoload": {
44 | "psr-4": {
45 | "Faker\\": "src/Faker/"
46 | }
47 | },
48 | "notification-url": "https://packagist.org/downloads/",
49 | "license": [
50 | "MIT"
51 | ],
52 | "authors": [
53 | {
54 | "name": "François Zaninotto"
55 | }
56 | ],
57 | "description": "Faker is a PHP library that generates fake data for you.",
58 | "keywords": [
59 | "data",
60 | "faker",
61 | "fixtures"
62 | ],
63 | "time": "2018-07-12T10:23:15+00:00"
64 | },
65 | {
66 | "name": "luoyy/blade",
67 | "version": "5.5.28",
68 | "source": {
69 | "type": "git",
70 | "url": "https://github.com/zishang520/blade.git",
71 | "reference": "dbe44f5868ef9df2f889c9f3fc5ef081e6f3da22"
72 | },
73 | "dist": {
74 | "type": "zip",
75 | "url": "https://api.github.com/repos/zishang520/blade/zipball/dbe44f5868ef9df2f889c9f3fc5ef081e6f3da22",
76 | "reference": "dbe44f5868ef9df2f889c9f3fc5ef081e6f3da22",
77 | "shasum": "",
78 | "mirrors": [
79 | {
80 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
81 | "preferred": true
82 | }
83 | ]
84 | },
85 | "require": {
86 | "php": ">=7.0.0"
87 | },
88 | "type": "library",
89 | "autoload": {
90 | "files": [
91 | "src/helpers.php"
92 | ],
93 | "psr-4": {
94 | "luoyy\\Blade\\": "src/"
95 | }
96 | },
97 | "notification-url": "https://packagist.org/downloads/",
98 | "license": [
99 | "MIT"
100 | ],
101 | "authors": [
102 | {
103 | "name": "luoyy",
104 | "email": "zishang520@gmail.com"
105 | }
106 | ],
107 | "description": "an independent version of laravel view template - blade",
108 | "homepage": "http://www.luoyy.com",
109 | "time": "2018-01-23T04:45:20+00:00"
110 | },
111 | {
112 | "name": "luoyy/think-blade",
113 | "version": "3.0.1",
114 | "source": {
115 | "type": "git",
116 | "url": "https://github.com/zishang520/think-blade.git",
117 | "reference": "ae498e63f26808f0b9bd1c24472c753e6478e9c1"
118 | },
119 | "dist": {
120 | "type": "zip",
121 | "url": "https://api.github.com/repos/zishang520/think-blade/zipball/ae498e63f26808f0b9bd1c24472c753e6478e9c1",
122 | "reference": "ae498e63f26808f0b9bd1c24472c753e6478e9c1",
123 | "shasum": "",
124 | "mirrors": [
125 | {
126 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
127 | "preferred": true
128 | }
129 | ]
130 | },
131 | "require": {
132 | "luoyy/blade": "^5.5",
133 | "php": ">=5.4.0"
134 | },
135 | "type": "library",
136 | "autoload": {
137 | "classmap": [
138 | {
139 | "think\\view\\driver\\Blade": "drivers/thinkphp5/Blade.php"
140 | }
141 | ]
142 | },
143 | "notification-url": "https://packagist.org/downloads/",
144 | "license": [
145 | "Apache-2.0"
146 | ],
147 | "authors": [
148 | {
149 | "name": "luoyy",
150 | "email": "zishang520@gmail.com"
151 | }
152 | ],
153 | "description": "think blade view engine",
154 | "homepage": "http://www.luoyy.com",
155 | "time": "2018-01-23T05:39:00+00:00"
156 | },
157 | {
158 | "name": "topthink/framework",
159 | "version": "v5.1.37.1",
160 | "source": {
161 | "type": "git",
162 | "url": "https://github.com/top-think/framework.git",
163 | "reference": "05eecd121d18d6705aaa10aa44fcdf7c14da4d0b"
164 | },
165 | "dist": {
166 | "type": "zip",
167 | "url": "https://api.github.com/repos/top-think/framework/zipball/05eecd121d18d6705aaa10aa44fcdf7c14da4d0b",
168 | "reference": "05eecd121d18d6705aaa10aa44fcdf7c14da4d0b",
169 | "shasum": "",
170 | "mirrors": [
171 | {
172 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
173 | "preferred": true
174 | }
175 | ]
176 | },
177 | "require": {
178 | "php": ">=5.6.0",
179 | "topthink/think-installer": "2.*"
180 | },
181 | "require-dev": {
182 | "johnkary/phpunit-speedtrap": "^1.0",
183 | "mikey179/vfsstream": "~1.6",
184 | "phpdocumentor/reflection-docblock": "^2.0",
185 | "phploc/phploc": "2.*",
186 | "phpunit/phpunit": "^5.0|^6.0",
187 | "sebastian/phpcpd": "2.*",
188 | "squizlabs/php_codesniffer": "2.*"
189 | },
190 | "type": "think-framework",
191 | "notification-url": "https://packagist.org/downloads/",
192 | "license": [
193 | "Apache-2.0"
194 | ],
195 | "authors": [
196 | {
197 | "name": "liu21st",
198 | "email": "liu21st@gmail.com"
199 | },
200 | {
201 | "name": "yunwuxin",
202 | "email": "448901948@qq.com"
203 | }
204 | ],
205 | "description": "the new thinkphp framework",
206 | "homepage": "http://thinkphp.cn/",
207 | "keywords": [
208 | "framework",
209 | "orm",
210 | "thinkphp"
211 | ],
212 | "time": "2019-05-28T06:57:29+00:00"
213 | },
214 | {
215 | "name": "topthink/think-installer",
216 | "version": "v2.0.0",
217 | "source": {
218 | "type": "git",
219 | "url": "https://github.com/top-think/think-installer.git",
220 | "reference": "f5400a12c60e513911aef41fe443fa6920952675"
221 | },
222 | "dist": {
223 | "type": "zip",
224 | "url": "https://api.github.com/repos/top-think/think-installer/zipball/f5400a12c60e513911aef41fe443fa6920952675",
225 | "reference": "f5400a12c60e513911aef41fe443fa6920952675",
226 | "shasum": "",
227 | "mirrors": [
228 | {
229 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
230 | "preferred": true
231 | }
232 | ]
233 | },
234 | "require": {
235 | "composer-plugin-api": "^1.0"
236 | },
237 | "require-dev": {
238 | "composer/composer": "1.0.*@dev"
239 | },
240 | "type": "composer-plugin",
241 | "extra": {
242 | "class": "think\\composer\\Plugin"
243 | },
244 | "autoload": {
245 | "psr-4": {
246 | "think\\composer\\": "src"
247 | }
248 | },
249 | "notification-url": "https://packagist.org/downloads/",
250 | "license": [
251 | "Apache-2.0"
252 | ],
253 | "authors": [
254 | {
255 | "name": "yunwuxin",
256 | "email": "448901948@qq.com"
257 | }
258 | ],
259 | "time": "2018-05-11T06:45:42+00:00"
260 | },
261 | {
262 | "name": "topthink/think-migration",
263 | "version": "v2.0.3",
264 | "source": {
265 | "type": "git",
266 | "url": "https://github.com/top-think/think-migration.git",
267 | "reference": "70c89850ca29c2eab988c7c3475d1d5331901bb8"
268 | },
269 | "dist": {
270 | "type": "zip",
271 | "url": "https://api.github.com/repos/top-think/think-migration/zipball/70c89850ca29c2eab988c7c3475d1d5331901bb8",
272 | "reference": "70c89850ca29c2eab988c7c3475d1d5331901bb8",
273 | "shasum": "",
274 | "mirrors": [
275 | {
276 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
277 | "preferred": true
278 | }
279 | ]
280 | },
281 | "require": {
282 | "topthink/framework": "5.1.*"
283 | },
284 | "type": "library",
285 | "autoload": {
286 | "psr-4": {
287 | "Phinx\\": "phinx/src/Phinx",
288 | "think\\migration\\": "src"
289 | },
290 | "files": [
291 | "src/config.php"
292 | ]
293 | },
294 | "notification-url": "https://packagist.org/downloads/",
295 | "license": [
296 | "Apache-2.0"
297 | ],
298 | "authors": [
299 | {
300 | "name": "yunwuxin",
301 | "email": "448901948@qq.com"
302 | }
303 | ],
304 | "time": "2017-12-31T16:32:22+00:00"
305 | }
306 | ],
307 | "packages-dev": [],
308 | "aliases": [],
309 | "minimum-stability": "stable",
310 | "stability-flags": [],
311 | "prefer-stable": false,
312 | "prefer-lowest": false,
313 | "platform": {
314 | "php": ">=5.6.0"
315 | },
316 | "platform-dev": []
317 | }
318 |
--------------------------------------------------------------------------------
/config/app.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | 应用设置
14 | // +----------------------------------------------------------------------
15 |
16 | return [
17 | // 应用名称
18 | 'app_name' => '',
19 | // 应用地址
20 | 'app_host' => '',
21 | // 应用调试模式
22 | 'app_debug' => true,
23 | // 应用Trace
24 | 'app_trace' => false,
25 | // 是否支持多模块
26 | 'app_multi_module' => true,
27 | // 入口自动绑定模块
28 | 'auto_bind_module' => false,
29 | // 注册的根命名空间
30 | 'root_namespace' => [],
31 | // 默认输出类型
32 | 'default_return_type' => 'html',
33 | // 默认AJAX 数据返回格式,可选json xml ...
34 | 'default_ajax_return' => 'json',
35 | // 默认JSONP格式返回的处理方法
36 | 'default_jsonp_handler' => 'jsonpReturn',
37 | // 默认JSONP处理方法
38 | 'var_jsonp_handler' => 'callback',
39 | // 默认时区
40 | 'default_timezone' => 'Asia/Shanghai',
41 | // 是否开启多语言
42 | 'lang_switch_on' => false,
43 | // 默认全局过滤方法 用逗号分隔多个
44 | 'default_filter' => '',
45 | // 默认语言
46 | 'default_lang' => 'zh-cn',
47 | // 应用类库后缀
48 | 'class_suffix' => false,
49 | // 控制器类后缀
50 | 'controller_suffix' => false,
51 |
52 | // +----------------------------------------------------------------------
53 | // | 模块设置
54 | // +----------------------------------------------------------------------
55 |
56 | // 默认模块名
57 | 'default_module' => 'index',
58 | // 禁止访问模块
59 | 'deny_module_list' => ['common'],
60 | // 默认控制器名
61 | 'default_controller' => 'Index',
62 | // 默认操作名
63 | 'default_action' => 'index',
64 | // 默认验证器
65 | 'default_validate' => '',
66 | // 默认的空模块名
67 | 'empty_module' => '',
68 | // 默认的空控制器名
69 | 'empty_controller' => 'Error',
70 | // 操作方法前缀
71 | 'use_action_prefix' => false,
72 | // 操作方法后缀
73 | 'action_suffix' => '',
74 | // 自动搜索控制器
75 | 'controller_auto_search' => false,
76 |
77 | // +----------------------------------------------------------------------
78 | // | URL设置
79 | // +----------------------------------------------------------------------
80 |
81 | // PATHINFO变量名 用于兼容模式
82 | 'var_pathinfo' => 's',
83 | // 兼容PATH_INFO获取
84 | 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
85 | // pathinfo分隔符
86 | 'pathinfo_depr' => '/',
87 | // HTTPS代理标识
88 | 'https_agent_name' => '',
89 | // IP代理获取标识
90 | 'http_agent_ip' => 'X-REAL-IP',
91 | // URL伪静态后缀
92 | 'url_html_suffix' => 'html',
93 | // URL普通方式参数 用于自动生成
94 | 'url_common_param' => false,
95 | // URL参数方式 0 按名称成对解析 1 按顺序解析
96 | 'url_param_type' => 0,
97 | // 是否开启路由延迟解析
98 | 'url_lazy_route' => false,
99 | // 是否强制使用路由
100 | 'url_route_must' => false,
101 | // 合并路由规则
102 | 'route_rule_merge' => false,
103 | // 路由是否完全匹配
104 | 'route_complete_match' => false,
105 | // 使用注解路由
106 | 'route_annotation' => false,
107 | // 域名根,如thinkphp.cn
108 | 'url_domain_root' => '',
109 | // 是否自动转换URL中的控制器和操作名
110 | 'url_convert' => true,
111 | // 默认的访问控制器层
112 | 'url_controller_layer' => 'controller',
113 | // 表单请求类型伪装变量
114 | 'var_method' => '_method',
115 | // 表单ajax伪装变量
116 | 'var_ajax' => '_ajax',
117 | // 表单pjax伪装变量
118 | 'var_pjax' => '_pjax',
119 | // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
120 | 'request_cache' => false,
121 | // 请求缓存有效期
122 | 'request_cache_expire' => null,
123 | // 全局请求缓存排除规则
124 | 'request_cache_except' => [],
125 | // 是否开启路由缓存
126 | 'route_check_cache' => false,
127 | // 路由缓存的Key自定义设置(闭包),默认为当前URL和请求类型的md5
128 | 'route_check_cache_key' => '',
129 | // 路由缓存类型及参数
130 | 'route_cache_option' => '',
131 |
132 | // 默认跳转页面对应的模板文件
133 | 'dispatch_success_tmpl' => Env::get('think_path') . 'tpl/dispatch_jump.tpl',
134 | 'dispatch_error_tmpl' => Env::get('think_path') . 'tpl/dispatch_jump.tpl',
135 |
136 | // 异常页面的模板文件
137 | 'exception_tmpl' => Env::get('think_path') . 'tpl/think_exception.tpl',
138 |
139 | // 错误显示信息,非调试模式有效
140 | 'error_message' => '页面错误!请稍后再试~',
141 | // 显示错误信息
142 | 'show_error_msg' => false,
143 | // 异常处理handle类 留空使用 \think\exception\Handle
144 | 'exception_handle' => '',
145 |
146 | ];
147 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | 缓存设置
14 | // +----------------------------------------------------------------------
15 |
16 | return [
17 | // 驱动方式
18 | 'type' => 'File',
19 | // 缓存保存目录
20 | 'path' => '',
21 | // 缓存前缀
22 | 'prefix' => '',
23 | // 缓存有效期 0表示永久缓存
24 | 'expire' => 0,
25 | ];
26 |
--------------------------------------------------------------------------------
/config/console.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | 控制台配置
14 | // +----------------------------------------------------------------------
15 | return [
16 | 'name' => 'Think Console',
17 | 'version' => '0.1',
18 | 'user' => null,
19 | ];
20 |
--------------------------------------------------------------------------------
/config/cookie.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | Cookie设置
14 | // +----------------------------------------------------------------------
15 | return [
16 | // cookie 名称前缀
17 | 'prefix' => '',
18 | // cookie 保存时间
19 | 'expire' => 0,
20 | // cookie 保存路径
21 | 'path' => '/',
22 | // cookie 有效域名
23 | 'domain' => '',
24 | // cookie 启用安全传输
25 | 'secure' => false,
26 | // httponly设置
27 | 'httponly' => '',
28 | // 是否使用 setcookie
29 | 'setcookie' => true,
30 | ];
31 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | return [
13 | // 数据库类型
14 | 'type' => 'mysql',
15 | // 服务器地址
16 | 'hostname' => '127.0.0.1',
17 | // 数据库名
18 | 'database' => 'thinkphp5-web-actual-1',
19 | // 用户名
20 | 'username' => 'root',
21 | // 密码
22 | 'password' => 'root',
23 | // 端口
24 | 'hostport' => '3306',
25 | // 连接dsn
26 | 'dsn' => '',
27 | // 数据库连接参数
28 | 'params' => [],
29 | // 数据库编码默认采用utf8
30 | 'charset' => 'utf8',
31 | // 数据库表前缀
32 | 'prefix' => '',
33 | // 数据库调试模式
34 | 'debug' => true,
35 | // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
36 | 'deploy' => 0,
37 | // 数据库读写是否分离 主从式有效
38 | 'rw_separate' => false,
39 | // 读写分离后 主服务器数量
40 | 'master_num' => 1,
41 | // 指定从服务器序号
42 | 'slave_no' => '',
43 | // 自动读取主库数据
44 | 'read_master' => false,
45 | // 是否严格检查字段是否存在
46 | 'fields_strict' => true,
47 | // 数据集返回类型
48 | 'resultset_type' => 'array',
49 | // 自动写入时间戳字段
50 | 'auto_timestamp' => 'timestamp',
51 | // 时间字段取出后的默认时间格式
52 | 'datetime_format' => 'Y-m-d H:i:s',
53 | // 是否需要进行SQL性能分析
54 | 'sql_explain' => false,
55 | // Builder类
56 | 'builder' => '',
57 | // Query类
58 | 'query' => '\\think\\db\\Query',
59 | // 是否需要断线重连
60 | 'break_reconnect' => false,
61 | // 断线标识字符串
62 | 'break_match_str' => [],
63 | ];
64 |
--------------------------------------------------------------------------------
/config/log.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | 日志设置
14 | // +----------------------------------------------------------------------
15 | return [
16 | // 日志记录方式,内置 file socket 支持扩展
17 | 'type' => 'File',
18 | // 日志保存目录
19 | 'path' => '',
20 | // 日志记录级别
21 | 'level' => [],
22 | // 单文件日志写入
23 | 'single' => false,
24 | // 独立日志级别
25 | 'apart_level' => [],
26 | // 最大日志文件数量
27 | 'max_files' => 0,
28 | // 是否关闭日志写入
29 | 'close' => false,
30 | ];
31 |
--------------------------------------------------------------------------------
/config/middleware.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | 中间件配置
14 | // +----------------------------------------------------------------------
15 | return [
16 | // 默认中间件命名空间
17 | 'default_namespace' => 'app\\http\\middleware\\',
18 | ];
19 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | 会话设置
14 | // +----------------------------------------------------------------------
15 |
16 | return [
17 | 'id' => '',
18 | // SESSION_ID的提交变量,解决flash上传跨域
19 | 'var_session_id' => '',
20 | // SESSION 前缀
21 | 'prefix' => 'think',
22 | // 驱动方式 支持redis memcache memcached
23 | 'type' => '',
24 | // 是否自动开启 SESSION
25 | 'auto_start' => true,
26 | ];
27 |
--------------------------------------------------------------------------------
/config/template.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | 模板设置
14 | // +----------------------------------------------------------------------
15 |
16 | return [
17 | // 模板引擎类型
18 | 'type' => 'Blade',
19 | // 视图基础目录(集中式)
20 | 'view_base' => Env::get('ROOT_PATH') . 'resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR,
21 | // 模板起始路径
22 | 'view_path' => Env::get('ROOT_PATH') . 'resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR,
23 | // 模板文件名分隔符
24 | 'view_depr' => DIRECTORY_SEPARATOR,
25 | // 模板文件后缀
26 | 'view_suffix' => 'blade.php',
27 | 'cache' => [
28 | 'cache_subdir' => false,
29 | 'prefix' => '',
30 | ],
31 | 'tpl_replace_string' => [],
32 | ];
33 |
--------------------------------------------------------------------------------
/config/trace.php:
--------------------------------------------------------------------------------
1 |
10 | // +----------------------------------------------------------------------
11 |
12 | // +----------------------------------------------------------------------
13 | // | Trace设置 开启 app_trace 后 有效
14 | // +----------------------------------------------------------------------
15 | return [
16 | // 内置Html Console 支持扩展
17 | 'type' => 'Html',
18 | ];
19 |
--------------------------------------------------------------------------------
/database/migrations/20180614013134_users.php:
--------------------------------------------------------------------------------
1 | table('users');
14 | $table->addColumn('name', 'string')
15 | ->addColumn('email', 'string')
16 | ->addColumn('password', 'string')
17 | ->addColumn('avatar', 'string', ['null' => true, 'default' => NULL, 'comment' => '用户头像'])
18 | ->addColumn('god', 'boolean', ['default' => FALSE, 'comment' => '管理员'])
19 | ->addTimestamps('created_at', 'updated_at')
20 | ->addIndex('email', ['unique' => true])
21 | ->addIndex('god')
22 | ->create();
23 | }
24 | /**
25 | * Migrate Down.
26 | */
27 | public function down()
28 | {
29 | $this->dropTable('users');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/database/migrations/20190728094237_posts.php:
--------------------------------------------------------------------------------
1 | table('posts');
14 | $table->addColumn('content', 'text')
15 | ->addColumn('user_id', 'integer')
16 | ->addTimestamps('created_at', 'updated_at')
17 | ->create();
18 | }
19 | /**
20 | * Migrate Down.
21 | */
22 | public function down()
23 | {
24 | $this->dropTable('posts');
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/database/seeds/Posts.php:
--------------------------------------------------------------------------------
1 | $faker->text,
16 | 'user_id' => $user_id,
17 | ];
18 | }
19 |
20 | $this->table('posts')->insert($data)->save();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/database/seeds/Users.php:
--------------------------------------------------------------------------------
1 | $faker->userName,
23 | 'password' => $faker->password,
24 | 'email' => $faker->email,
25 | ];
26 | }
27 |
28 | $this->table('users')->insert($data)->save();
29 |
30 | // allowField(false) 屏蔽 Model 中设置的保护字段 $field
31 | User::get(1)->allowField(false)->save([
32 | 'god' => true
33 | ]);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/extend/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
21 | {{ $post->content }} 22 |
23 | {{ $post->created_at }} 24 |