Skip to content

StubWriter ​

php
final class Zairakai\LaravelDevTools\Services\StubWriter

Writes a file of the package in a project: a file that equals the stub is refreshed, one that differs is left alone, and --force replaces it after a copy in .dev-tools-backup/.

Source: src/Services/StubWriter.php

Methods ​

__construct() ​

php
public function __construct(PublishOutput $output)

ensureDirectory() ​

php
public function ensureDirectory(string $directory): void

Create the given directory recursively if it does not already exist.

publish() ​

php
public function publish(string $basePath, string $stubFile, string $targetFile, bool $force, string $label): bool

Core workflow for copying a stub file to its target location.

ParameterDescription
$stubFileAbsolute path to the stub file
$targetFileAbsolute path to the target file
$forceWhether to overwrite an existing file
$labelHuman-readable label for console output

saveBeforeOverwriting() ​

php
public function saveBeforeOverwriting(string $basePath, string $file): bool

Keeps a copy of a file that a forced publication is about to write over, in .dev-tools-backup/ (the same folder as the shell scripts use). Nothing is kept when the file does not exist.

skip() ​

php
public function skip(string $label, string $reason, string $color = 'yellow'): void

Display a skipped-file message in the console.

Documentation of 5.5.0 , built from 92a7387 on 5.5.0 by pipeline #3086393151 on 2026-11-18.