Using stubs in commands
To use stubs in commands, use the GeneratesFiles trait in your command.
use Javaabu\GeneratorHelpers\Concerns\GeneratesFiles;
use Illuminate\Console\Command;
class FactoryGenerateCommand extends Command
{
use GeneratesFiles;
...
Available Methods
The trait will add the following methods to your command.
getFilesystem(): Returns the Laravel Filesystem instancegetRenderer(): Returns aStubRendererinstancegetFullFilePath(string $path, string $file_name): Returns the full file path with the file name appended to the path.getPath(string $default, string $path = ''): Returns thedefaultpath if nopathgiven. Otherwise, returns the full absolute path relative to the project base path.appendContent(string $file_path, array $contents, string $stub = ''): If the given file exists, appends the given contents to that file usingStubRendererappendMultipleContentmethod. Otherwise, creates a new file at the given file path using the given stub and appends the content.putContent(string $file_path, string $content, bool $force = false): Creates a file at the given file path with the given content. Returns an error if file already exists, unless using theforceoption. When using theforceoption, the file is overwritten.alreadyExists(string $path): Checks if a given file already exists.makeDirectory(string $path): Creates a directory at the given path.