| @@ 153-168 (lines=16) @@ | ||
| 150 | * @throws \Spatie\DbDumper\Exceptions\CannotStartDump |
|
| 151 | * @throws \Spatie\DbDumper\Exceptions\DumpFailed |
|
| 152 | */ |
|
| 153 | public function dumpToFile(string $dumpFile) |
|
| 154 | { |
|
| 155 | $this->guardAgainstIncompleteCredentials(); |
|
| 156 | ||
| 157 | $tempFileHandle = tmpfile(); |
|
| 158 | fwrite($tempFileHandle, $this->getContentsOfCredentialsFile()); |
|
| 159 | $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri']; |
|
| 160 | ||
| 161 | $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile); |
|
| 162 | ||
| 163 | $process = Process::fromShellCommandline($command, null, null, null, $this->timeout); |
|
| 164 | ||
| 165 | $process->run(); |
|
| 166 | ||
| 167 | $this->checkIfDumpWasSuccessFul($process, $dumpFile); |
|
| 168 | } |
|
| 169 | ||
| 170 | public function addExtraOption(string $extraOption) |
|
| 171 | { |
|
| @@ 37-54 (lines=18) @@ | ||
| 34 | * @throws \Spatie\DbDumper\Exceptions\CannotStartDump |
|
| 35 | * @throws \Spatie\DbDumper\Exceptions\DumpFailed |
|
| 36 | */ |
|
| 37 | public function dumpToFile(string $dumpFile) |
|
| 38 | { |
|
| 39 | $this->guardAgainstIncompleteCredentials(); |
|
| 40 | ||
| 41 | $command = $this->getDumpCommand($dumpFile); |
|
| 42 | ||
| 43 | $tempFileHandle = tmpfile(); |
|
| 44 | fwrite($tempFileHandle, $this->getContentsOfCredentialsFile()); |
|
| 45 | $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri']; |
|
| 46 | ||
| 47 | $envVars = $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile); |
|
| 48 | ||
| 49 | $process = Process::fromShellCommandline($command, null, $envVars, null, $this->timeout); |
|
| 50 | ||
| 51 | $process->run(); |
|
| 52 | ||
| 53 | $this->checkIfDumpWasSuccessFul($process, $dumpFile); |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * Get the command that should be performed to dump the database. |
|