Service.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace think\migration;
  12. use Faker\Factory as FakerFactory;
  13. use Faker\Generator as FakerGenerator;
  14. use think\migration\command\factory\Create as FactoryCreate;
  15. use think\migration\command\migrate\Breakpoint as MigrateBreakpoint;
  16. use think\migration\command\migrate\Create as MigrateCreate;
  17. use think\migration\command\migrate\Rollback as MigrateRollback;
  18. use think\migration\command\migrate\Run as MigrateRun;
  19. use think\migration\command\migrate\Status as MigrateStatus;
  20. use think\migration\command\seed\Create as SeedCreate;
  21. use think\migration\command\seed\Run as SeedRun;
  22. class Service extends \think\Service
  23. {
  24. public function boot()
  25. {
  26. $this->app->bind(FakerGenerator::class, function () {
  27. return FakerFactory::create($this->app->config->get('app.faker_locale', 'zh_CN'));
  28. });
  29. $this->app->bind(Factory::class, function () {
  30. return (new Factory($this->app->make(FakerGenerator::class)))->load($this->app->getRootPath() . 'database/factories/');
  31. });
  32. $this->app->bind('migration.creator', Creator::class);
  33. $this->commands([
  34. MigrateCreate::class,
  35. MigrateRun::class,
  36. MigrateRollback::class,
  37. MigrateBreakpoint::class,
  38. MigrateStatus::class,
  39. SeedCreate::class,
  40. SeedRun::class,
  41. FactoryCreate::class,
  42. ]);
  43. }
  44. }