@@ -18,84 +18,9 @@ Install via Composer:
1818}
1919```
2020
21- ## Usage
21+ ## Documentation
2222
23- There are two things you need to generate code.
24-
25- 1 . A generator
26- * CodeGenerator
27- * CodeFileGenerator
28- 2 . A model to generate
29- * PhpClass
30- * PhpInterface
31- * PhpTrait
32- * PhpFunction
33-
34- You can create these models and push all the data using a fluent API or read from existing code through reflection.
35-
36- ### Generate Code
37-
38- a) Simple:
39-
40- ``` php
41- use gossi\codegen\generator\CodeGenerator;
42- use gossi\codegen\model\PhpClass;
43- use gossi\codegen\model\PhpMethod;
44- use gossi\codegen\model\PhpParameter;
45-
46- $class = new PhpClass();
47- $class->setName('my\cool\Tool');
48- ->setMethod(PhpMethod::create('__construct')
49- ->addParameter(PhpParameter::create('target')
50- ->setType('string')
51- ->setDescription('Creates my Tool')
52- )
53- );
54-
55- $generator = new CodeGenerator();
56- $code = $generator->generate($class);
57- ```
58-
59- b) From Reflection:
60-
61- ``` php
62- use gossi\codegen\generator\CodeGenerator;
63- use gossi\codegen\model\PhpClass;
64-
65- $class = PhpClass::fromReflection(new \ReflectionClass('MyClass'));
66-
67- $generator = new CodeGenerator();
68- $code = $generator->generate($class);
69- ```
70-
71- ### Code Generators
72-
73- The package ships with two generators, which are configurable with an associative array as constructor parameter. Alternatively if you have a project that uses the same configuration over and over again, extend the respective config object and pass it instead of the configuration array.
74-
75- ** CodeGenerator**
76-
77- Creates code for a given model
78-
79- Config: ` gossi\codegen\config\CodeGeneratorConfig ` <br >
80- Options:
81-
82- | Key | Type | Default Value | Description |
83- | --- | ---- | ------------- | ----------- |
84- | generateDocblock | boolean | true | enables docblock generation prior to code generation |
85- | generateEmptyDocblock | boolean | true | when docblock generation is enabled, even empty docblocks will be generated |
86-
87- ** CodeFileGenerator**
88-
89- Creates a complete php file with the given model inside.
90-
91- Config: ` gossi\codegen\config\CodeFileGeneratorConfig ` <br >
92- Options: Same options as ` CodeGenerator ` plus:
93-
94- | Key | Type | Default Value | Description |
95- | --- | ---- | ------------- | ----------- |
96- | headerComment | string | empty | A comment, that will be put after the <?php statement |
97- | headerDocblock | string\| Docblock | empty | A docblock that will be positioned after the possible header comment |
98- | blankLineAtEnd | boolean | true | Places an empty line at the end of the generated file |
23+ Documentation is available at [ https://php-code-generator.readthedocs.org ] ( https://php-code-generator.readthedocs.org )
9924
10025## Contributing
10126
0 commit comments