2017 © Pedro Peláez
 

library laravel-stubs

Easily store stubs for your project to reuse whenever needed.

image

owenmelbz/laravel-stubs

Easily store stubs for your project to reuse whenever needed.

  • Saturday, September 2, 2017
  • by OwenMelbz
  • Repository
  • 2 Watchers
  • 54 Stars
  • 798 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 50 % Grown

The README.md

Laravel Stub Helper

We often find outselves having to repeat the same boilerplating when creating new files such as javascript components, blade templates etc., (*1)

This package aims to help save your brain cells for the more important things in life (like pizza) by enabling you scaffold the things you're always repeating within a project by taking influence from the other make: commands., (*2)

Installation

1- Install via composer composer require owenmelbz/laravel-stubs., (*3)

2- The package should use laravels new auto discovery, if not however you can manually register the service provider - typically done inside the app.php providers array e.g OwenMelbz\LaravelStubs\StubsServiceProvider::class., (*4)

3- If you're going to be modifying the default stubs, or adding your own stubs, you'll need to publish the config using php artisan vendor:publish --tag=stubs-config which will generate config/template_stubs.php, (*5)

Usage

Run php artisan make:a {stub} {name} this will generate you a new file, based off the defined stub, (*6)

The {name} will become the filename and typically the class/component name where the default @placeholder marker is used within the files., (*7)

Default stubs

You can view a full list of the default stubs from the config file -> https://github.com/OwenMelbz/Laravel-Stubs/blob/master/src/config/template_stubs.php, (*8)

Modifying existing stubs

If you want to modify a default stub you can do this in 2 different ways., (*9)

The stubs are loaded in a waterfall style - so if you have your own file inside your resources/stubs folder we will use this file instead., (*10)

You can either use the same filename that is defined within the stub key of the config e.g vue-component.js and we'll use that. Or you can create a file of any name and change the stub key in a published config file., (*11)

If you want to modify every stub in the package, you can publish all the stubs in 1 go using php artisan vendor:publish --tag=stubs-stubs which will place them all in your resources/stubs folder., (*12)

Adding custom stubs

You can either publish the default config and modify it, or create your own called template_stubs.php - if you wanted you could even use php artisan make:a config template_stubs and start adding your own., (*13)

Creating a new stub requires at minimum, a stub file, an output path, and a name. Below is an example structure, (*14)

'my-stub' => [
    'stub' => 'my-stub.php',
    'output_path' => resource_path('some-folder')
]

It's worth noting that the file extension of the outputted file will match that of the stub file. So in this instance we do not recommend using .stub as your file extension., (*15)

During the generation process we parse a token called @placeholder anywhere this marker is within your stub, will get replaced by the name you passed into the command. e.g, (*16)

This command artisan make:a vue my-component will see a file, (*17)

Vue.component('@placeholder', {

});

and generate my-component.js with the content, (*18)

Vue.component('my-component', {

});

If you want to change @placeholder to something else add the placeholder => '@myothername' to the stub definition within the config., (*19)

Contributing community stubs

Please feel free to submit pull requests to add custom stubs, make sure there are no naming conflicts, and keep them as simple as possible., (*20)

Typically we adhear to a PSR-2 style for php files, I may modify the code style to make it consistent with submitted stubs., (*21)

Notes

This is a very new package, has not been heavily used in the wild, so please bare with me if you stumble across bugs, always add a PR where possible to fix issues as its massively appreciated., (*22)

Thank :D, (*23)

The Versions

02/09 2017

dev-master

9999999-dev

Easily store stubs for your project to reuse whenever needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Owen Melbourne

laravel templates stubs

02/09 2017

0.0.5

0.0.5.0

Easily store stubs for your project to reuse whenever needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Owen Melbourne

laravel templates stubs

02/09 2017

0.0.4

0.0.4.0

Easily store stubs for your project to reuse whenever needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Owen Melbourne

laravel templates stubs

02/09 2017

0.0.3

0.0.3.0

Easily store stubs for your project to reuse whenever needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Owen Melbourne

laravel templates stubs

26/08 2017

0.0.2

0.0.2.0

Easily store stubs for your project to reuse whenever needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Owen Melbourne

laravel templates stubs

26/08 2017

0.0.1

0.0.1.0

Easily store stubs for your project to reuse whenever needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Owen Melbourne

laravel templates stubs