douxiong5972 2018-03-10 13:07
浏览 238

`--database`在laravel中的“Artisan :: call”方法中不起作用

I am using to set database dynamically and running migration to update database to create all table. with below command

Artisan::call("migrate",['--database'=>'new_database','--path'=>'database/migrations/company']);

But I am always getting this error

1/1 InvalidArgumentException in DatabaseManager.php line 239: Database [new_database] not configured.

In my database.php is have created connection as

'company' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => '',
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => false,
            'engine' => null,
        ],

Pleas help me to understand.

  • 写回答

2条回答 默认 最新

  • doujunchi1238 2018-03-10 15:13
    关注

    Try This

    Artisan::call("migrate",['--database'=>'company','--path'=>'database/migrations/company']);

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?