提交 d15aea76 编写于 作者: Y yuenblue

Merge branch 'master' of gitcode.net:yuencczzy/phpdemo

......@@ -5,7 +5,7 @@ DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
HOSTNAME = localhost
DATABASE = demotp6
USERNAME = root
PASSWORD = root
......
<?php
namespace app\controller;
use app\BaseController;
use think\facade\View;
class User extends BaseController
{
public function index()
{
return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">16载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';
}
public function hello($name = 'ThinkPHP6')
{
return 'hello,' . $name;
}
function login() {
// return View::engine("php")->fetch('user/login');
// return View::fetch('user/login');
return $this->app->view->fetch();
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>登录页面~!</h1>
</body>
</html>
\ No newline at end of file
......@@ -23,7 +23,8 @@
"php": ">=7.2.5",
"topthink/framework": "^6.1.0",
"topthink/think-orm": "^2.0",
"topthink/think-filesystem": "^1.0"
"topthink/think-filesystem": "^1.0",
"topthink/think-view": "^2.0"
},
"require-dev": {
"symfony/var-dumper": "^4.2",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "7571874c932d1e243ba0fd635cc0bfc7",
"content-hash": "c6839ac29846e44be67cec1ba557e486",
"packages": [
{
"name": "league/flysystem",
......@@ -671,6 +671,88 @@
"source": "https://github.com/top-think/think-orm/tree/v2.0.61"
},
"time": "2023-04-20T14:27:51+00:00"
},
{
"name": "topthink/think-template",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-template.git",
"reference": "4352d2cf627abfb8b49f830686c25c02f59c23f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-template/zipball/4352d2cf627abfb8b49f830686c25c02f59c23f2",
"reference": "4352d2cf627abfb8b49f830686c25c02f59c23f2",
"shasum": ""
},
"require": {
"php": ">=8.0.0",
"psr/simple-cache": ">=1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"think\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "liu21st",
"email": "liu21st@gmail.com"
}
],
"description": "the php template engine",
"support": {
"issues": "https://github.com/top-think/think-template/issues",
"source": "https://github.com/top-think/think-template/tree/v3.0.0"
},
"time": "2023-02-25T12:11:14+00:00"
},
{
"name": "topthink/think-view",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-view.git",
"reference": "d2a076011c96d2edd8016703a827fb54b2683c62"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-view/zipball/d2a076011c96d2edd8016703a827fb54b2683c62",
"reference": "d2a076011c96d2edd8016703a827fb54b2683c62",
"shasum": ""
},
"require": {
"php": ">=8.0.0",
"topthink/think-template": "^3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"think\\view\\driver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "liu21st",
"email": "liu21st@gmail.com"
}
],
"description": "thinkphp template driver",
"support": {
"issues": "https://github.com/top-think/think-view/issues",
"source": "https://github.com/top-think/think-view/tree/v2.0.0"
},
"time": "2023-02-25T12:18:09+00:00"
}
],
"packages-dev": [
......
......@@ -22,17 +22,17 @@ return [
'connections' => [
'mysql' => [
// 数据库类型
'type' => env('database.type', 'mysql'),
'type' => env('database.type'),
// 服务器地址
'hostname' => env('database.hostname', '127.0.0.1'),
'hostname' => env('database.hostname'),
// 数据库名
'database' => env('database.database', 'demotp6'),
'database' => env('database.database'),
// 用户名
'username' => env('database.username', 'root'),
'username' => env('database.username'),
// 密码
'password' => env('database.password', ''),
'password' => env('database.password'),
// 端口
'hostport' => env('database.hostport', '3306'),
'hostport' => env('database.hostport'),
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
......
......@@ -15,7 +15,7 @@ namespace think;
require __DIR__ . '/../vendor/autoload.php';
// 执行HTTP应用并响应
$http = (new App())->http;
$http = (new App())->setEnvName('example')->http;
$response = $http->run();
......
......@@ -10,6 +10,12 @@
// +----------------------------------------------------------------------
use think\facade\Route;
Route::group('user',function(){
Route::get('/','user/index');
Route::get('index','user/index');
Route::get('login','user/login');
});
Route::group("demo",function(){
Route::get('say','demo/say');
......
......@@ -43,15 +43,33 @@ class DemoTp6 extends TestCase{
// assertTrue(true);
// table方法必须指定完整的数据表名
// $aa=Db::table('tp6_user')->where('id', 1)->find();
$app=App();
$aa=$app->db->table('tp6_user')->find(2);
var_dump($aa);
// $aa=Db::table('tp6_user')->find(2);
// var_dump($aa);
$app = app();
$user = User::find(1);
$user->username='bbbb';
$user->save();
// $app = app();
// $user = new User();
// $user->username='cccc';
// $user->password='dddd';
// $user->save();
// $user = User::find(2);
// $user->username='eeee';
// $user->save();
// assertTrue($aa);
$this->assertNotEmpty($user);
$this->assertNotEmpty(true);
}
function testCache() {
Cache::get("")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册