Skip to content

Commit 05ad905

Browse files
committed
prepare Changelog and Readme for v3.0
1 parent 836b821 commit 05ad905

File tree

2 files changed

+118
-28
lines changed

2 files changed

+118
-28
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,24 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
2121
### Security
2222
- Nothing
2323

24-
## 3.0.0 - 2018-06-XX
24+
## 3.0.0 - 2018-06-24 - Complete Refactoring
2525

26+
The Refactoring is supposed to provide new functions more easily in the future.
2627

28+
Attention: `schema` has been changed and only registered FieldTypes (see config-file) will be parsed. There are only a few FieldTypes available at the moment, more will come soon.
29+
30+
### Added
31+
32+
- `AddToGitService`: using `--git` in command will add all files to git
33+
34+
### Changed
35+
36+
- The parsing of `--schema=""` is now a bit different, but much more powerful. Please see Readme for further information
37+
- Naming for each service is handled by dedicated classes and can be accessed everywhere (e.g. name of Model inside a CrudController)
38+
39+
### Removed
40+
41+
- additional commands which are now integrated in the corresponding services
2742

2843
## 2.1.0 - 2018-03-30 (for Backpack Base v0.9)
2944

README.md

Lines changed: 102 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,48 +23,123 @@ composer require-dev webfactor/laravel-generators
2323
## Usage
2424

2525
``` bash
26-
php artisan make:entity {entity_name} {--schema=} {--ide=}
26+
php artisan make:entity {entity_name} {--schema=} {--migrate} {--ide=} {--git}
2727
```
2828

29-
`--schema` currently uses syntax from [Laravel 5 Extended Generators](https://github.com/laracasts/Laravel-5-Generators-Extended)
29+
- `entity_name`: Recommendation: use *singular* for entity. see "[Naming](#naming)" for more information
30+
- `--schema=`: Here you can provide a [schema-String](#schema)
31+
- `--migrate`: will automatically call `php artisan migrate` after creating the migration file
32+
- `--ide=`: will open all files in your prefered [IDE](#open-files-in-ide)
33+
- `--git`: will add all files to [git](#add-files-to-git)
3034

31-
Use *singular* for entity. This will automatically create (while respecting our internal naming conventions):
35+
If you want to add Services, Naming classes, Field Types, or IDE Opener you have to publish the config-file:
3236

33-
* Migration
34-
* Factory
35-
* Seeder
36-
* Backpack CRUD (modified Backpack Generator):
37-
* Model (incl. `$fillable`)
38-
* Request (incl. `rules()`)
39-
* Controller (incl. CrudColumns and CrudFields, basic for now)
40-
* Language File
41-
* Route to Backpack CRUD in admin.php
37+
``` bash
38+
php artisan vendor:publish --provider="Webfactor\Laravel\Generators\GeneratorsServiceProvider"
39+
```
40+
41+
## Services
42+
43+
All Services defined in the config file have to implement `Webfactor\Laravel\Generators\Contracts\ServiceInterface` and will then be called in the given order.
44+
45+
### Included Services
46+
47+
Can be removed or extended by publishing config file:
48+
49+
- `MigrationService`
50+
- `FactoryService`
51+
- `SeederService`
52+
- Backpack CRUD:
53+
- `BackpackCrudModelService` (incl. `$fillable`)
54+
- `BackpackCrudRequestService` (incl. `rules()`)
55+
- `BackpackCrudControllerService` (incl. CrudColumns and CrudFields, more coming soon)
56+
- `SidebarService`
57+
- `LanguageFileService`
58+
- `RouteFileService`
59+
60+
### Always available (activated by option):
4261

43-
### Open files in IDE
62+
- `OpenIdeService`
63+
- `AddToGitService`
4464

45-
With `{--ide=}` option you can define your preferred IDE to open all automatically generated files. This package comes with an implementation for PhpStorm (`Webfactor\Laravel\Generators\RecipesPhpStormOpener`) which is defined in `generators.php`. The keys in the `ides`-Array are possible values for the command option. You can add other IDE-Opener classes, they have to implement `Webfactor\Laravel\Generators\Contracts\OpenInIdeInterface`.`
65+
## Schema
4666

47-
In your service class you have to define the path to the file generated by this service. Then add `$this->addLatestFileToIdeStack();` and all files of the stack will be opened by `Webfactor\Laravel\Generators\Services\OpenIdeService`.
67+
The intention of this package concerning Laravel Backpack CRUD is to provide an easy way to define standard Field Types with some default options and override them if necessary.
4868

4969
Example:
5070

51-
```php
52-
<?php
71+
``` bash
72+
php artisan make:entity blog --schema="title:string,text:summernote"
73+
```
74+
75+
This will use the `StringType` and `SummernoteType` classes to create (besides all other files):
5376

54-
class ExampleService extends ServiceAbstract implements ServiceInterface
55-
{
56-
protected $relativeToBasePath = 'path/to/file';
77+
- Blog.php with `$fillable = ['title', 'text']`
78+
- BlogRequest.php with predefined rules for each field
79+
- BlogCrudController.php with columns and fields for `title` and `text`
5780

58-
public function call()
59-
{
60-
// do some magic
81+
If you want to add/overwrite certain options you can use something like this:
6182

62-
// searches for latest file (using modified date) in given directory and adds it to the stack
63-
$this->addLatestFileToIdeStack();
64-
}
65-
}
83+
``` bash
84+
php artisan make:entity blog --schema="title:string(unique|default:title);rule(required|min:3|max:64),text:summernote;field(label:Content);column(label:Content)"
6685
```
6786

87+
## Field Types
88+
89+
Currently available Field Types (more coming soon):
90+
91+
- Date
92+
- Number
93+
- String
94+
- Summernote (as a proof of concept)
95+
- Text
96+
97+
The available definitions in the Field Type classes currently are:
98+
99+
```php
100+
public $validationRule; // 'required|min:5'...
101+
102+
public $migrationField = [
103+
'type' => 'string', // any type available for a migration file
104+
// optional:
105+
// 'unique' => true
106+
// 'default' => 'value'
107+
// 'nullable' => true
108+
// etc.
109+
];
110+
111+
public $crudColumn = [
112+
'type' => 'text', // or date, number, any backpack column
113+
// 'label' => 'Name of label'
114+
// ... any option
115+
];
116+
117+
public $crudField = [
118+
'type' => 'text', // or date, number, any backpack field
119+
// 'label' => 'Name of label'
120+
// ... prefix, suffix... any option
121+
];
122+
```
123+
124+
## Naming
125+
126+
`// to be written`
127+
128+
## Add files to git
129+
130+
With `{--git}` option all generated files will be added to git automatically. In your service class you have to add the generated file. You can:
131+
132+
- use `$this->command->addFile(SplileInfo $file)` or
133+
- use `$this->addGeneratedFileToIdeStack()` if you use a naming key or
134+
- use the `Webfactor\Laravel\Generators\Traits\CanGenerateFile` define a naming key and just implement a `buildFileContent()` method
135+
136+
## Open files in IDE
137+
138+
With `{--ide=}` option you can define your preferred IDE to open all automatically generated files. This package comes with an implementation for PhpStorm (`Webfactor\Laravel\Generators\RecipesPhpStormOpener`) which is defined in `generators.php`. The keys in the `ides`-Array are possible values for the command option. You can add other IDE-Opener classes, they have to implement `Webfactor\Laravel\Generators\Contracts\OpenInIdeInterface`.
139+
140+
In your service class you have to add the generated file to a stack (see "Add files to git" section)
141+
142+
68143
## Adaption
69144

70145
Feel free to write your own Services that fit your purposes!

0 commit comments

Comments
 (0)