jeroen-g / laravel-builder
Build rapidly classes based on stubs.
Requires
- php: ~5.5|~7.0
- illuminate/console: ~5
- illuminate/filesystem: ~5
- illuminate/support: ~5
Requires (Dev)
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2022-02-01 12:56:01 UTC
README
Build your Laravel application from the command line or, at some point in the future, through an interface.
Install
Via Composer
$ composer require jeroen-g/laravel-builder
In config/app.php add
JeroenG\LaravelBuilder\LaravelBuilderServiceProvider::class,
Usage
In your code
An instance of the builder class is binded in the service provider. You can use the Builder in your code in one of the following ways.
Stubs are searched in the stubs/
directory, so run the command first (see next section).
- With variables
$builder->stub = 'model'; // model.stub found in stubs/ $builder->namespace = 'App\\Models'; $builder->class = 'Test'; $builder->path = 'app/Models/Test'; // Relative to base_path(). $builder->run()->save(); // Creates and then saves the file. $builder->reset(); // Resets the variables for a completely new build process.
- With an array
$builder->fromArray([ 'stub' => 'model', 'namespace' => 'App\\Models', 'class' => 'Test', 'path' => 'app/Models/Test' ]); // No need to run() or save() or reset().
- With Json
$json = json_encode([ // You could for example have .json files for this. 'stub' => 'model', 'namespace' => 'App\\Models', 'class' => 'Test', 'path' => 'app/Models/Test' ]); $builder->fromJson($json); // No need to run() or save() or reset().
The command line
You can also use the following commands.
- Publish all the included stubs to the
stubs/
directory.
$ php artisan build:stubs
You can add your own stubs to this directory as well. It currently ships with very little stubs, if you have made your own, feel free to add them to the package with a Pull Request.
- Building a file
$ php artisan build model App\\Models Test app/Models/Test
Through the web interface
After installing the package and publishing the stubs, the web interface is accessible by visiting /builder
. You can create single files or a resource (controller, model, form request, policy, migration, views).
Change log
Please see changelog for more information what has changed recently.
Testing
$ composer test
Contributing
Please see contributing for details.
Credits
License
The EUPL License. Please see the License File for more information.