很多站长朋友们都不太清楚phinxphp,今天小编就来给大家整理phinxphp,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 php pdo扩展问题 2、 如何在PHP项目中使用phinx进行数据迁移和建表 php pdo扩展问题就跟楼上的说的差不多 php.ini 首先找到你的php.ini文件 用phpinfor()看看 你的ini文件在什么地方 找到后打开 找你上面提示的那几个文件 如果有把前面的分号“;”去掉 如果没得 用同样的方式加上 然后再到ext文件夹下面看看那几个文件在不在 不在可以到网上去下 完了你还可以开启ini模块测试提示 看那些还没配置好 完了就差不多了 重启一下
如何在PHP项目中使用phinx进行数据迁移和建表建表
phinx\bin\phinx.bat migrate -e production
建设 phinx.yml文件
paths:
migrations: %%PHINX_CONFIG_DIR%%\database\migrations
seeds: %%PHINX_CONFIG_DIR%%\database\seeds
environments:
default_migration_table: phinxlog
default_database: development
production:
adapter: mysql
host: localhost
name: jitamin2
user: root
pass: ‘‘
port: 3306
charset: utf8
development:
adapter: mysql
host: localhost
name: development_db
user: root
pass: ‘‘
port: 3306
charset: utf8
testing:
adapter: mysql
host: localhost
name: testing_db
user: root
pass: ‘‘
port: 3306
charset: utf8
数据迁移命令如下:
phinx\bin\phinx.bat seed:run -e production
%%PHINX_CONFIG_DIR%%\database\seeds下面的文件示例CreateGroupsTable.php如下:
<?php
/*
* This file is part of Jitamin.
*
* Copyright (C) Jitamin Team
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Jitamin\Foundation\Security\Role;
use Phinx\Seed\AbstractSeed;
class UserSeeder extends AbstractSeed
{
/**
* Run Method.
*/
public function run()
{
$data = [
[
‘username‘ => ‘admin‘,
‘password‘ => bcrypt(‘admin‘),
‘email‘ => ‘admin@admin测试数据‘,
‘role‘ => Role::APP_ADMIN,
],
];
$users = $this->table(‘users‘);
$users->insert($data)
->save();
}
}
关于phinxphp的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。