Package Data | |
---|---|
Maintainer Username: | dam1r89 |
Maintainer Contact: | ivanmijatovic89@gmail.com (Ivan Mijatovic) |
Package Create Date: | 2014-09-03 |
Package Last Update: | 2017-07-20 |
Home Page: | |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-11 15:20:37 |
Package Statistics | |
---|---|
Total Downloads: | 263 |
Monthly Downloads: | 1 |
Daily Downloads: | 1 |
Total Stars: | 6 |
Total Watchers: | 6 |
Total Forks: | 2 |
Total Open Issues: | 1 |
Install
composer require "dam1r89/proto-generator" --dev
Add to config/app.php
under the providers key, but before application providers.
dam1r89\ProtoGenerator\ProtoGeneratorServiceProvider::class,
If you want to edit templates you can publish them.
php artisan vendor:publish --tag="proto-generator"
To scaffold resource with name post you type:
php artisan proto post --fields='{"name":{}, "body":{}, "rating": {"type": "number"}}'
fields flag is json data which is transferred to the templates.
and add bindings to the routes.php
file:
Route::resource('post', 'PostsController');
then go to local serving address, for example on http://localhost:8000/posts and you can see simple crud application.
For hasOne relation use field name and id: "category_id": {"label": "name"}
.
-r replace files withouth asking
-t template folder - default standard
-f fields
-d additional context data
-o output folder - default base
use dam1r89\ProtoGenerator\ContextDataParser;
use dam1r89\ProtoGenerator\Proto;
$parser = new ContextDataParser('users', ['first_name', 'last_name']);
$context = $parser->getContextData();
$context['additional_data'] = 'whatever';
$p = Proto::create('source/path/', base_path(), $context);
$p->generate(true);