Build your Laravel application from the command line or, at some point in the future, through an interface.
Via Composer
$ composer require jeroen-g/laravel-builder
In config/app.php add
JeroenG\LaravelBuilder\LaravelBuilderServiceProvider::class,
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().
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
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).
Please see changelog for more information what has changed recently.
$ composer test
Please see contributing for details.
The EUPL License. Please see the License File for more information.