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`
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
This diff is collapsed.
<?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