Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/skyronic/laravel-file-generator

A Laravel package which helps you automate creation of files.
https://github.com/skyronic/laravel-file-generator

boilerplate generator laravel

Last synced: about 4 hours ago
JSON representation

A Laravel package which helps you automate creation of files.

Awesome Lists containing this project

README

        

# Laravel file generator

This is a Laravel package which helps you automate creation of files.

### Benefits

* If you create a type of file frequently, you can automate it and improve productivity.
* Prevent "context switching" where you lose focus for 30 seconds while you create new files, directories and populate it with boilerplate.
* Comes with several built-in boilerplates. Easy to share your own as github gists.
* All boilerplates and generators are part of your repository, letting you share standard templates with your team.
* Find things like `artisan make:model` and `artisan make:controller` useful? You can make your own.
* All boilerplates can be written as blade templates.

## Quick Start

**Step 1**: Install the package

```bash
$ composer require skyronic/laravel-file-generator
```

**Step 2**: Publish the "boilerplates" - an included set of useful boilerplates like PHP Classes.

```bash
$ php artisan vendor:publish --tag='boilerplates'
```

**Step 3**: You can list all the installed boilerplates

```bash
$ php artisan generate:list

+---------------+------------------------------+
| Type | Name |
+---------------+------------------------------+
| css | CSS File |
| js | JavaScript File |
| php:class | PHP Class in 'app' Directory |
| php:trait | PHP Trait in 'app' Directory |
| view | Blade Template |
+---------------+------------------------------+

Use `artisan generate ` to create a new file!
```

**Step 5**: You can create a php class now:

```bash
$ php artisan generate php:class "Support/Helpers/AwesomeHelper" --extends "BaseHelper" --constructor

Created file [ app/Support/Helpers/AwesomeHelper.php ]
```

The generator `php:class` creates one by default in. You can now open app/Support/Helpers/AwesomeHelper.php

```php
"App\Support\Helpers"

// For non `app` directories, you need to manually specify namespace routes
// $path = "tests/Unit/HelperTests/AwesomeHelperTest.php"
Format::getNamespace ($path, 'tests', "Tests")
// -> "Tests\Unit\HelperTests"
```

## Example: PHP Class generator

First, be sure that you've run `php artisan vendor:publish --tag='boilerplates'` and check `app/resources/boilerplates/php__class.boilerplate.txt`

```
{
"name": "PHP Class in 'app' Directory",
"out": "app/{{ $name }}.php",
"params": {
"extends": "optional",
"constructor": "flag"
}
}
---