Commit 7b0452a0 authored by Nemo Ma's avatar Nemo Ma Committed by GitHub

Merge pull request #101 from nahakyuu/add_yii3_framework

add yii3 framework database support & add dev doc
parents 3ca5d68c e81d6570
FROM php:5.4-fpm
FROM php:8.1-fpm
RUN docker-php-ext-install mysqli && docker-php-ext-install mbstring
RUN docker-php-ext-install mysqli
COPY ./ /mnt/dts
RUN chmod -R 777 /mnt/dts
......
......@@ -30,12 +30,9 @@ bash ./bot/bot_enable.sh
## 开发注意
1. 使用`composer install`安装依赖
2. `./yii serve`命令在windows下会报错,[原因点我](https://github.com/yiisoft/yii-console/issues/175),临时解决方案
找到`vendor\yiisoft\yii-console\src\Command\Serve.php`文件,修改第138行中的`'PHP_CLI_SERVER_WORKERS=' . $workers .`部分,变成以下代码
```php
passthru('"' . PHP_BINARY . '"' . " -S $address -t \"$documentRoot\" $router");
```
2. 可以使用`./yii serve`来启动开发版服务器
3. 修改`config/configuration.php`之后一定要运行`composer du`来重新生成`.merge-plan.php`
4. 目前只加入了`src``config`文件夹,demo文件见`C:\git\phpdts\src\Controller\HomeController.php`
\ No newline at end of file
4. 目前只加入了`src``config`文件夹,demo文件见`C:\git\phpdts\src\Controller\HomeController.php`
5. 可以使用[Yii Dev Panel](https://yiisoft.github.io/yii-dev-panel)来调试
6. 数据库配置请修改 `config\common\params.php`,默认使用`Yiisoft\Db\Mysql\ConnectionPDO`
7. 目前只用了`yii serve`使用php原生自带的Routing file功能做路由,nginx和`.htaccess`在做了在做了
\ No newline at end of file
......@@ -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": "2d0df35e2ca77cf06cd0f0898782f20d",
"content-hash": "44c30f2908958d905c354f1c41d950e1",
"packages": [
{
"name": "alexkart/curl-builder",
......@@ -1227,6 +1227,87 @@
],
"time": "2022-10-16T01:01:54+00:00"
},
{
"name": "yiisoft/active-record",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/active-record.git",
"reference": "e029fb40c2ec8fb578d2e277e82c5b5bd4a034a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/active-record/zipball/e029fb40c2ec8fb578d2e277e82c5b5bd4a034a2",
"reference": "e029fb40c2ec8fb578d2e277e82c5b5bd4a034a2",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^8.0",
"yiisoft/db": "^3.0@dev",
"yiisoft/factory": "^1.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.6|^10.0",
"rector/rector": "^0.14",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.3|^5.6",
"yiisoft/aliases": "^2.0",
"yiisoft/cache": "^2.0|^3.0",
"yiisoft/db-mssql": "^1.0@dev",
"yiisoft/db-mysql": "^3.0@dev",
"yiisoft/db-oracle": "^1.0@dev",
"yiisoft/db-pgsql": "^3.0@dev",
"yiisoft/db-sqlite": "^3.0@dev",
"yiisoft/di": "^1.0",
"yiisoft/event-dispatcher": "^1.0",
"yiisoft/json": "^1.0",
"yiisoft/log": "^2.0"
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Yiisoft\\ActiveRecord\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Yii ActiveRecord Library",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"Active Record",
"yii"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/active-record/issues",
"source": "https://github.com/yiisoft/active-record",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "open_collective"
}
],
"time": "2023-03-12T17:30:00+00:00"
},
{
"name": "yiisoft/aliases",
"version": "3.0.0",
......@@ -1663,6 +1744,164 @@
],
"time": "2023-02-15T13:28:02+00:00"
},
{
"name": "yiisoft/db",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/db.git",
"reference": "270b6b1e9ddaac0483632fd792668f638dd346d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/db/zipball/270b6b1e9ddaac0483632fd792668f638dd346d9",
"reference": "270b6b1e9ddaac0483632fd792668f638dd346d9",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-pdo": "*",
"php": "^8.0",
"psr/log": "^2.0|^3.0",
"psr/simple-cache": "^2.0|^3.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.6|^10.0",
"rector/rector": "^0.14",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.6",
"yiisoft/aliases": "^1.1|^2.0",
"yiisoft/cache-file": "^2.0",
"yiisoft/di": "^1.0",
"yiisoft/event-dispatcher": "^1.0",
"yiisoft/json": "^1.0",
"yiisoft/log": "^2.0",
"yiisoft/var-dumper": "^1.5"
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Yiisoft\\Db\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Yii DataBase Library",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"database",
"yii"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/db/issues/issues?state=open",
"source": "https://github.com/yiisoft/db",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "open_collective"
}
],
"time": "2023-03-30T18:15:20+00:00"
},
{
"name": "yiisoft/db-mysql",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/db-mysql.git",
"reference": "c17e36b2b11b2afdd38eec1c396fd081c22423cd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/db-mysql/zipball/c17e36b2b11b2afdd38eec1c396fd081c22423cd",
"reference": "c17e36b2b11b2afdd38eec1c396fd081c22423cd",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-json": "*",
"ext-pdo": "*",
"php": "^8.0",
"psr/log": "^2.0|^3.0",
"yiisoft/db": "^3.0@dev",
"yiisoft/json": "^1.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5|^10.0",
"rector/rector": "^0.14",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.3|^5.6",
"yiisoft/aliases": "^2.0",
"yiisoft/cache": "^2.0",
"yiisoft/cache-file": "^2.0",
"yiisoft/log-target-file": "^2.0",
"yiisoft/var-dumper": "^1.5"
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Yiisoft\\Db\\Mysql\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Yii DataBase MySQL Extension",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"mysql",
"yii"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/db-mysql/issues",
"source": "https://github.com/yiisoft/db-mysql",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "open_collective"
}
],
"time": "2023-03-29T20:20:55+00:00"
},
{
"name": "yiisoft/definitions",
"version": "3.2.0",
......@@ -1961,6 +2200,69 @@
],
"time": "2022-10-27T12:02:21+00:00"
},
{
"name": "yiisoft/factory",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/factory.git",
"reference": "e93903c7960d0ff5897a9e36ff3b0ecb3ab25a8d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/factory/zipball/e93903c7960d0ff5897a9e36ff3b0ecb3ab25a8d",
"reference": "e93903c7960d0ff5897a9e36ff3b0ecb3ab25a8d",
"shasum": ""
},
"require": {
"php": "^8.0",
"psr/container": "^1.0|^2.0",
"yiisoft/definitions": "^1.0|^2.0|^3.0.1"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.14.3",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18",
"yiisoft/test-support": "^1.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Yiisoft\\Factory\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Yii Factory",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"factory"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/factory/issues",
"source": "https://github.com/yiisoft/factory",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "open_collective"
}
],
"time": "2022-11-08T08:54:16+00:00"
},
{
"name": "yiisoft/files",
"version": "2.0.0",
......@@ -4121,16 +4423,16 @@
},
{
"name": "symfony/console",
"version": "v6.2.7",
"version": "v6.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45"
"reference": "3582d68a64a86ec25240aaa521ec8bc2342b369b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/cbad09eb8925b6ad4fb721c7a179344dc4a19d45",
"reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45",
"url": "https://api.github.com/repos/symfony/console/zipball/3582d68a64a86ec25240aaa521ec8bc2342b369b",
"reference": "3582d68a64a86ec25240aaa521ec8bc2342b369b",
"shasum": ""
},
"require": {
......@@ -4192,12 +4494,12 @@
"homepage": "https://symfony.com",
"keywords": [
"cli",
"command line",
"command-line",
"console",
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v6.2.7"
"source": "https://github.com/symfony/console/tree/v6.2.8"
},
"funding": [
{
......@@ -4213,7 +4515,7 @@
"type": "tidelift"
}
],
"time": "2023-02-25T17:00:03+00:00"
"time": "2023-03-29T21:42:15+00:00"
},
{
"name": "symfony/deprecation-contracts",
......@@ -4592,16 +4894,16 @@
},
{
"name": "symfony/process",
"version": "v6.2.7",
"version": "v6.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "680e8a2ea6b3f87aecc07a6a65a203ae573d1902"
"reference": "75ed64103df4f6615e15a7fe38b8111099f47416"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/680e8a2ea6b3f87aecc07a6a65a203ae573d1902",
"reference": "680e8a2ea6b3f87aecc07a6a65a203ae573d1902",
"url": "https://api.github.com/repos/symfony/process/zipball/75ed64103df4f6615e15a7fe38b8111099f47416",
"reference": "75ed64103df4f6615e15a7fe38b8111099f47416",
"shasum": ""
},
"require": {
......@@ -4633,7 +4935,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v6.2.7"
"source": "https://github.com/symfony/process/tree/v6.2.8"
},
"funding": [
{
......@@ -4649,7 +4951,7 @@
"type": "tidelift"
}
],
"time": "2023-02-24T10:42:00+00:00"
"time": "2023-03-09T16:20:02+00:00"
},
{
"name": "symfony/service-contracts",
......@@ -4738,16 +5040,16 @@
},
{
"name": "symfony/string",
"version": "v6.2.7",
"version": "v6.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "67b8c1eec78296b85dc1c7d9743830160218993d"
"reference": "193e83bbd6617d6b2151c37fff10fa7168ebddef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/67b8c1eec78296b85dc1c7d9743830160218993d",
"reference": "67b8c1eec78296b85dc1c7d9743830160218993d",
"url": "https://api.github.com/repos/symfony/string/zipball/193e83bbd6617d6b2151c37fff10fa7168ebddef",
"reference": "193e83bbd6617d6b2151c37fff10fa7168ebddef",
"shasum": ""
},
"require": {
......@@ -4804,7 +5106,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v6.2.7"
"source": "https://github.com/symfony/string/tree/v6.2.8"
},
"funding": [
{
......@@ -4820,7 +5122,7 @@
"type": "tidelift"
}
],
"time": "2023-02-24T10:42:00+00:00"
"time": "2023-03-20T16:06:02+00:00"
},
{
"name": "symfony/yaml",
......@@ -5632,16 +5934,16 @@
},
{
"name": "yiisoft/yii-console",
"version": "2.0.0",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii-console.git",
"reference": "783e08add57abc6090a12ae52608f2fe856bd425"
"reference": "55de5e6d3bcfccfc5fd6f39379ef192e142f7712"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii-console/zipball/783e08add57abc6090a12ae52608f2fe856bd425",
"reference": "783e08add57abc6090a12ae52608f2fe856bd425",
"url": "https://api.github.com/repos/yiisoft/yii-console/zipball/55de5e6d3bcfccfc5fd6f39379ef192e142f7712",
"reference": "55de5e6d3bcfccfc5fd6f39379ef192e142f7712",
"shasum": ""
},
"require": {
......@@ -5709,7 +6011,7 @@
"type": "opencollective"
}
],
"time": "2023-02-17T10:42:22+00:00"
"time": "2023-03-31T08:30:43+00:00"
},
{
"name": "yiisoft/yii-debug",
......@@ -5717,12 +6019,12 @@
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii-debug.git",
"reference": "20b397a336d7f31a227ac4f5f75d8c8d81ae0b89"
"reference": "fcb51240f0995eec2772da9047a87b80130e20b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii-debug/zipball/20b397a336d7f31a227ac4f5f75d8c8d81ae0b89",
"reference": "20b397a336d7f31a227ac4f5f75d8c8d81ae0b89",
"url": "https://api.github.com/repos/yiisoft/yii-debug/zipball/fcb51240f0995eec2772da9047a87b80130e20b8",
"reference": "fcb51240f0995eec2772da9047a87b80130e20b8",
"shasum": ""
},
"require": {
......@@ -5821,7 +6123,7 @@
"type": "open_collective"
}
],
"time": "2023-03-29T06:20:37+00:00"
"time": "2023-03-30T18:21:42+00:00"
},
{
"name": "yiisoft/yii-debug-api",
......@@ -5829,12 +6131,12 @@
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii-debug-api.git",
"reference": "5467dcf073ae2ff3cf807f8577a4ae3ac400c4f8"
"reference": "faf2cd9b89be733c68144467133458d4b1f8321f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii-debug-api/zipball/5467dcf073ae2ff3cf807f8577a4ae3ac400c4f8",
"reference": "5467dcf073ae2ff3cf807f8577a4ae3ac400c4f8",
"url": "https://api.github.com/repos/yiisoft/yii-debug-api/zipball/faf2cd9b89be733c68144467133458d4b1f8321f",
"reference": "faf2cd9b89be733c68144467133458d4b1f8321f",
"shasum": ""
},
"require": {
......@@ -5928,7 +6230,7 @@
"type": "open_collective"
}
],
"time": "2023-03-15T10:32:55+00:00"
"time": "2023-03-30T19:52:08+00:00"
},
{
"name": "yiisoft/yii-gii",
......@@ -6261,6 +6563,9 @@
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"yiisoft/active-record": 20,
"yiisoft/db": 20,
"yiisoft/db-mysql": 20,
"yiisoft/request-model": 20,
"yiisoft/yii-debug": 20,
"yiisoft/yii-debug-api": 20,
......
<?php
declare(strict_types=1);
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Mysql\ConnectionPDO;
use Yiisoft\Db\Driver\PDO\PDODriverInterface;
use Yiisoft\Db\Mysql\PDODriver;
return [
ConnectionInterface::class => ConnectionPDO::class,
PDODriverInterface::class => PDODriver::class,
PDODriver::class => [
'__construct()' => [
'dsn' => $params['db']['dsn'],
'username' => $params['db']['username'],
'password' => $params['db']['password'],
]
]
];
......@@ -2,6 +2,18 @@
declare(strict_types=1);
use Yiisoft\Db\Mysql\Dsn;
$db = [
'driver' => 'mysql',
'host' => 'localhost',
'databaseName' => 'acdts3',
'port' => '3306',
'options' => ['charset' => 'utf8mb4'],
'username' => 'root',
'password' => 'mylittlepony',
];
return [
'app' => [
'charset' => 'UTF-8',
......@@ -20,4 +32,13 @@ return [
'@vendor' => '@root/vendor',
],
],
'db' => array_merge($db, [
'dsn' => (new Dsn(
$db['driver'],
$db['host'],
$db['databaseName'],
$db['port'],
$db['options']
))->asString(),
]),
];
<?php
declare(strict_types=1);
use Yiisoft\Definitions\DynamicReference;
use Yiisoft\Definitions\Reference;
use Yiisoft\Definitions\ReferencesArray;
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Yii\Http\Handler\NotFoundHandler;
use Yiisoft\Session\SessionMiddleware;
use Yiisoft\Csrf\CsrfMiddleware;
use Yiisoft\Router\Middleware\Router;
......
......@@ -17,11 +17,21 @@ services:
- nginx_conf:/etc/nginx/conf.d
db:
image: mariadb:10
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: "mylittlepony"
MYSQL_DATABASE: "acdts3"
volumes:
- db:/var/lib/mysql
phpmyadmin:
image: phpmyadmin:5.2.1
ports:
- 8081:80
environment:
- PMA_HOST=db
- PMA_USER=root
- PMA_PASSWORD=mylittlepony
volumes:
db:
dts:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment