Supported Versions: PHP 5, PHP 7, PHP 8
Write data to a file
file_put_contents( string $filename, mixed $data, int $flags = 0, ?resource $context = null): int|false
public function refreshDatabaseFile()
{
file_put_contents($this->connection->getDatabaseName(), '');
}
}
{
file_put_contents($this->connection->getDatabaseName(), '');
}
}
public function put($path, $contents, $lock = false)
{
return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
}
{
return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
}
chmod($tempPath, 0777 - umask());
file_put_contents($tempPath, $content);
rename($tempPath, $path);
}
file_put_contents($tempPath, $content);
rename($tempPath, $path);
}
public function replaceInFile($search, $replace, $path)
{
file_put_contents($path, str_replace($search, $replace, file_get_contents($path)));
}
{
file_put_contents($path, str_replace($search, $replace, file_get_contents($path)));
}
public function append($path, $data)
{
return file_put_contents($path, $data, FILE_APPEND);
}
{
return file_put_contents($path, $data, FILE_APPEND);
}
return $path;
}
file_put_contents($path, $this->formatFacadeStub(
$alias, file_get_contents(__DIR__.'/stubs/facade.stub')
));
return $path;
}
}
file_put_contents($path, $this->formatFacadeStub(
$alias, file_get_contents(__DIR__.'/stubs/facade.stub')
));
return $path;
}
return;
}
file_put_contents(
$path,
'<div>
<!-- '.Inspiring::quote().' -->
</div>'
);
if ($onSuccess) {
$onSuccess();
}
file_put_contents(
$path,
'<div>
<!-- '.Inspiring::quote().' -->
</div>'
);
if ($onSuccess) {
$onSuccess();
$this->laravel->maintenanceMode()->activate($this->getDownFilePayload());
file_put_contents(
storage_path('framework/maintenance.php'),
file_get_contents(__DIR__.'/stubs/maintenance-mode.stub')
);
$this->laravel->get('events')->dispatch(MaintenanceModeEnabled::class);
file_put_contents(
storage_path('framework/maintenance.php'),
file_get_contents(__DIR__.'/stubs/maintenance-mode.stub')
);
$this->laravel->get('events')->dispatch(MaintenanceModeEnabled::class);
{
$this->callSilent('event:clear');
file_put_contents(
$this->laravel->getCachedEventsPath(),
'<?php return '.var_export($this->getEvents(), true).';'
);
$this->components->info('Events cached successfully.');
}
$this->callSilent('event:clear');
file_put_contents(
$this->laravel->getCachedEventsPath(),
'<?php return '.var_export($this->getEvents(), true).';'
);
$this->components->info('Events cached successfully.');
}
protected function writeNewEnvironmentFileWith($key)
{
file_put_contents($this->laravel->environmentFilePath(), preg_replace(
$this->keyReplacementPattern(),
'APP_KEY='.$key,
file_get_contents($this->laravel->environmentFilePath())
));
}
{
file_put_contents($this->laravel->environmentFilePath(), preg_replace(
$this->keyReplacementPattern(),
'APP_KEY='.$key,
file_get_contents($this->laravel->environmentFilePath())
));
}
foreach ($files as $from => $to) {
if ((! $this->option('existing') && (! file_exists($to) || $this->option('force')))
|| ($this->option('existing') && file_exists($to))) {
file_put_contents($to, file_get_contents($from));
}
}
if ((! $this->option('existing') && (! file_exists($to) || $this->option('force')))
|| ($this->option('existing') && file_exists($to))) {
file_put_contents($to, file_get_contents($from));
}
}
public function activate(array $payload): void
{
file_put_contents(
$this->path(),
json_encode($payload, JSON_PRETTY_PRINT)
);
}
{
file_put_contents(
$this->path(),
json_encode($payload, JSON_PRETTY_PRINT)
);
}
$tempFile = $tempFileInfo['dirname'].'/'.$tempFileInfo['filename'].'.blade.php';
file_put_contents($tempFile, $template);
return new TestView(view($tempFileInfo['filename'], $data));
}
file_put_contents($tempFile, $template);
return new TestView(view($tempFileInfo['filename'], $data));
}
$body = $response->getBody()->getContents();
if (is_string($sink)) {
file_put_contents($sink, $body);
return;
}
if (is_string($sink)) {
file_put_contents($sink, $body);
return;
}
mkdir($directory, 0755, true);
}
file_put_contents($viewFile, $contents);
}
return '__components::'.basename($viewFile, '.blade.php');
}
file_put_contents($viewFile, $contents);
}
return '__components::'.basename($viewFile, '.blade.php');