| @@ 157-176 (lines=20) @@ | ||
| 154 | * @throws \Spatie\DbDumper\Exceptions\CannotStartDump |
|
| 155 | * @throws \Spatie\DbDumper\Exceptions\DumpFailed |
|
| 156 | */ |
|
| 157 | public function dumpToFile($dumpFile) |
|
| 158 | { |
|
| 159 | $this->guardAgainstIncompleteCredentials(); |
|
| 160 | ||
| 161 | $command = $this->getDumpCommand($dumpFile); |
|
| 162 | ||
| 163 | $tempFileHandle = tmpfile(); |
|
| 164 | fwrite($tempFileHandle, $this->getContentsOfCredentialsFile()); |
|
| 165 | $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri']; |
|
| 166 | ||
| 167 | $process = new Process($command, null, $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile)); |
|
| 168 | ||
| 169 | if (!is_null($this->timeout)) { |
|
| 170 | $process->setTimeout($this->timeout); |
|
| 171 | } |
|
| 172 | ||
| 173 | $process->run(); |
|
| 174 | ||
| 175 | $this->checkIfDumpWasSuccessFul($process, $dumpFile); |
|
| 176 | } |
|
| 177 | ||
| 178 | /** |
|
| 179 | * Get the command that should be performed to dump the database. |
|
| @@ 178-197 (lines=20) @@ | ||
| 175 | * @throws \Spatie\DbDumper\Exceptions\CannotStartDump |
|
| 176 | * @throws \Spatie\DbDumper\Exceptions\DumpFailed |
|
| 177 | */ |
|
| 178 | public function dumpToFile($dumpFile) |
|
| 179 | { |
|
| 180 | $this->guardAgainstIncompleteCredentials(); |
|
| 181 | ||
| 182 | $tempFileHandle = tmpfile(); |
|
| 183 | fwrite($tempFileHandle, $this->getContentsOfCredentialsFile()); |
|
| 184 | $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri']; |
|
| 185 | ||
| 186 | $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile); |
|
| 187 | ||
| 188 | $process = new Process($command); |
|
| 189 | ||
| 190 | if (!is_null($this->timeout)) { |
|
| 191 | $process->setTimeout($this->timeout); |
|
| 192 | } |
|
| 193 | ||
| 194 | $process->run(); |
|
| 195 | ||
| 196 | $this->checkIfDumpWasSuccessFul($process, $dumpFile); |
|
| 197 | } |
|
| 198 | ||
| 199 | /** |
|
| 200 | * Get the command that should be performed to dump the database. |
|