PHPackages                             shamaseen/laravel-files-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. shamaseen/laravel-files-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shamaseen/laravel-files-generator
=================================

Generate any kind of File/s from stubs with only a single command, literally, ANY TYPE.

0.5.2(3y ago)113.5k↓43.3%1MITPHPPHP &gt;=7.4

Since Sep 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mshamaseen/laravel-files-generator)[ Packagist](https://packagist.org/packages/shamaseen/laravel-files-generator)[ RSS](/packages/shamaseen-laravel-files-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (8)Used By (1)

laravel-files-generator
=======================

[](#laravel-files-generator)

Generate any kind of file/s from stubs with only a single command, literally, ANY KIND.

[![Build](https://camo.githubusercontent.com/ed45590611760ef7bb6efe044e289089cc998d55e8c5de165c2bb9167cca7836/68747470733a2f2f6170702e7472617669732d63692e636f6d2f6d7368616d617365656e2f6c61726176656c2d66696c65732d67656e657261746f722e7376673f6272616e63683d6d61696e)](https://app.travis-ci.com/mshamaseen/laravel-files-generator)[![Licence](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://choosealicense.com/licenses/mit/)

Quickstart
----------

[](#quickstart)

### Generate a single file:

[](#generate-a-single-file)

From command line:

```
php artisan generate:stub pathToStub.stub pathToOutput.extension --replace='key 1' --with='value 1' --replace="key 2" --with='value 2'
```

On runtime:

```
FilesGenerator::stub('PathToYourStubFile.extension')
        ->replace('string to be replaced','The replacement value')
        ->output('outputPath.extension');
```

### Generate multiple files:

[](#generate-multiple-files)

From command line:

```
php artisan generate:config 'pathToYourConfig/configFileName.php'
```

On runtime:

```
FilesGenerator::fromConfigFile('configPath.php');
```

### Remove generated files from a config file:

[](#remove-generated-files-from-a-config-file)

From command line:

```
php artisan ungenerate:config 'pathToYourConfig/configFileName.php'
```

On runtime:

```
FilesUngenerator::fromConfigFile('configPath.php');
```

Installation
------------

[](#installation)

Run:

```
composer require shamaseen/laravel-files-generator

```

Publish the package config file

```
php artisan vendor:publish --provider='Shamaseen\Generator\GeneratorServiceProvider'
```

Configuration files
-------------------

[](#configuration-files)

To generate multiple files from config you will need to create a config file first, a config file is a php file that **MUST** return an array, either one-dimensional array or multi-dimensional array, depends on how many files you want to generate.

for example, to generate 2 files from 2 stubs with a single command, first create your conf:

```
