Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2. // Add to app/start/artisan.php
  3. // Artisan::add(new MysqlDump);
  4. use Illuminate\Console\Command;
  5. use Symfony\Component\Console\Input\InputOption;
  6. use Symfony\Component\Console\Input\InputArgument;
  7. class MysqlDump extends Command {
  8. /**
  9. * The console command name.
  10. *
  11. * @var string
  12. */
  13. protected $name = 'MysqlDump';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Create A MysqlDump SQL dump into the test database for acceptance testing in Codeception';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return mixed
  33. */
  34. public function fire()
  35. {
  36. $host = Config::get('database.connections.mysql.host');
  37. $database = Config::get('database.connections.mysql.database');
  38. $username = Config::get('database.connections.mysql.username');
  39. $password = Config::get('database.connections.mysql.password');
  40. $backupPath = app_path() . '/tests/_data/dump.sql';
  41. // Sending some info to the console for really debugging purposes if needed.
  42. $this->info('MysqlDump of database: ' . $database . ' - Export Started ...');
  43. $this->info('... Processing into ... ' . $backupPath);
  44. $this->info('We need your database password!');
  45. $path = "/usr/bin/mysqldump";
  46. $command = $path . " -u " . $username . " -p " . $database . " > " . $backupPath;
  47. //$command = $path . " -u " . $username . " " . $database . " > " . $backupPath;
  48. system($command);
  49. $this->info('MysqlDump has been completed!');
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement