| @@ 40-57 (lines=18) @@ | ||
| 37 | * @throws \Spatie\DbDumper\Exceptions\CannotStartDump |
|
| 38 | * @throws \Spatie\DbDumper\Exceptions\DumpFailed |
|
| 39 | */ |
|
| 40 | public function dumpToFile(string $dumpFile) |
|
| 41 | { |
|
| 42 | $this->guardAgainstIncompleteCredentials(); |
|
| 43 | ||
| 44 | $command = $this->getDumpCommand($dumpFile); |
|
| 45 | ||
| 46 | $tempFileHandle = tmpfile(); |
|
| 47 | fwrite($tempFileHandle, $this->getContentsOfCredentialsFile()); |
|
| 48 | $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri']; |
|
| 49 | ||
| 50 | $envVars = $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile); |
|
| 51 | ||
| 52 | $process = Process::fromShellCommandline($command, null, $envVars, null, $this->timeout); |
|
| 53 | ||
| 54 | $process->run(); |
|
| 55 | ||
| 56 | $this->checkIfDumpWasSuccessFul($process, $dumpFile); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Get the command that should be performed to dump the database. |
|
| @@ 189-204 (lines=16) @@ | ||
| 186 | * @throws \Spatie\DbDumper\Exceptions\CannotStartDump |
|
| 187 | * @throws \Spatie\DbDumper\Exceptions\DumpFailed |
|
| 188 | */ |
|
| 189 | public function dumpToFile(string $dumpFile) |
|
| 190 | { |
|
| 191 | $this->guardAgainstIncompleteCredentials(); |
|
| 192 | ||
| 193 | $tempFileHandle = tmpfile(); |
|
| 194 | fwrite($tempFileHandle, $this->getContentsOfCredentialsFile()); |
|
| 195 | $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri']; |
|
| 196 | ||
| 197 | $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile); |
|
| 198 | ||
| 199 | $process = Process::fromShellCommandline($command, null, null, null, $this->timeout); |
|
| 200 | ||
| 201 | $process->run(); |
|
| 202 | ||
| 203 | $this->checkIfDumpWasSuccessFul($process, $dumpFile); |
|
| 204 | } |
|
| 205 | ||
| 206 | public function addExtraOption(string $extraOption) |
|
| 207 | { |
|