| |
|
![]() |
vbs/VBScript DOS/BAT hta htc python perl 游戏相关 VBA 远程脚本 ColdFusion ruby专题 autoit seraphzone PowerShell linux shell Lua Golang Erlang 其它教程 CSS/HTML/Xhtml html5 CSS XML/XSLT Dreamweaver教程 经验交流 |
-> PHP -> laravel5.4使用migration数据库迁移建表 -> 正文阅读 |
[PHP]laravel5.4使用migration数据库迁移建表 |
首先要保证laravel的.env文件中的数据库链接已经创建好,在这里我使用的是MYSQL数据库1 DB_CONNECTION=mysql //数据库 2 DB_HOST=127.0.0.1 //服务器IP地址 3 DB_PORT=3306 //数据库的端口 4 DB_DATABASE=larvael54 //数据库名 5 DB_USERNAME=root //数据库用户名 6 DB_PASSWORD=root //数据库密码 在这里我用的是PHP storm命令行 输入创建migration命令 比如创建users表 PHP artisan make:migration create_users_table 注意:创建migration文件名为create_表名_table,创建成功会在database目录下的migrations目录下创建一个 2017_12_6_205846_create_users_table.php文件,打开文件输入代码 <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { //这里是你要创建表的字段属性 $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } } 文件创建成功后在PHP storm命令行中输入 PHP artisan migrate 执行完成后,建表成功。 |
PHP 最新文章 |
PHP中被忽略的性能优化利器:生成器 |
cakephp搭建配置完成后怎么关闭cake标识 |
如何配置php session使用redis集群 |
cakephp怎么默认显示index/index文件 |
PHP入门怎么选?大学生适合学习吗? |
php 回调函数和匿名函数 |
php |
[MarsZ]ThinkPHP项目实战总结 |
初始化当前平台 |
php文件及文件夹操作(创建、删除、移动、复 |
上一篇文章 下一篇文章 查看所有文章 |
|
360图书馆
软件开发资料
购物精选
新闻资讯
Chinese Culture
龙发科技
开发
中国文化
阅读网
日历
万年历
2021年1日历 2021-1-26 13:04:58 |
|
网站联系: qq:121756557 email:121756557@qq.com 编程知识 |