Download the PHP package lingyun/think-migration without Composer

On this page you can find all versions of the php package lingyun/think-migration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package think-migration

thinkphp6 数据库迁移工具

安装

数据库迁移

生成迁移文件

编辑迁移文件

运行迁移文件

回滚迁移文件

设置迁移断点

migrate:breakpoint 命令用来设置断点,可以使你对回滚进行限制。你可以调用 breakpoint 命令不带任何参数,即将断点设在最新的迁移脚本上

可以使用 --target 或者 -t 来指定断点打到哪个迁移版本上

可以使用 --remove-all 或者-r 来移除所有断点

查看迁移状态

输出格式:text 或者 json,默认输出text

或者

数据填充

创建Seeder类

seeder 类只包含一个默认方法:run。这个方法会在执行 php think seed:run 命令时被调用。在 run 方法里,你可以根据需要在数据库中插入数据。你也可以用 构造查询器 或 模型工厂 来手动插入数据。

运行 Seeders

您可以使用 php think seed:run 来填充数据库。默认情况下将运行 database/seeds 目录下所有Seeder类,可以使用 --seed 选项来指定一个特定的 seeder 类:

使用模型工厂

使用 模型工厂 轻松地生成大量数据库数据。

例如,创建 50 个用户并为每个用户创建关联:

模型工厂

创建工厂

要创建工厂,请执行 php think factory:create 命令:

新创建的工厂类默认存放在 database/factories 目录下。

以上就是模型工厂的最基本形式,调用 define 闭包方法返回伪造的模型属性值集合,该集合会在使用模型工厂创建新的模型实例时应用到模型属性。

通过 $faker 参数,可以访问 Faker PHP 函数库, 它允许你便捷的生成各种随机数据来进行测试。具体属性和方法请参考\Faker\Generator类。

技巧:你也可以在 config/app.php 配置文件中添加 faker_locale 选项来设置 Faker 的语言环境。

可以使用 define 方法的第三个参数为模型工厂设置名称

工厂状态

状态操作方法允许你定义离散修改,可以以任意组合应用于模型工厂。通常调用工厂类提供的 state 方法:

同时 也可以使用闭包:

使用工厂创建模型

让我们来看看一些创建模型的例子。首先,我们将使用 make 方法来创建模型而不存储到数据库:

可以使用times方法创建一个包含多个模型的集合:

还可以使用state方法应用任意定义的状态到模型类:

如果你想要应用多个状态转化到模型类,可以使用states方法:

覆盖属性

如果你想覆盖模型的一些默认值,你可以将数组传递给 make 方法。只有指定值才会被替换,剩下值保持工厂指定的默认值不变:

模型存储

create 方法创建模型实例,并使用 think\Modelsave 方法其存储到数据库中:

更多模型工厂用法自行研究


All versions of think-migration with dependencies

PHP Build Version
Package Version
Requires topthink/framework Version ^6.0 || ^8.0
fakerphp/faker Version ^1.19
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lingyun/think-migration contains the following files

Loading the files please wait ....