You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default `php-converter` writes all the types into one file. You can configure it to put each type / class in a separate file with all the required imports. Here is an example how to achieve it:
You can even go further and use `NegationFilter` to exclude specific files as shown in [unit tests](https://github.com/riverwaysoft/php-converter/blob/a8d5df2c03303c02bc9148bd1d7822d7fe48c5d8/tests/EndToEndTest.php#L297).
@@ -135,16 +134,16 @@ You can even go further and use `NegationFilter` to exclude specific files as sh
You may want to apply some transformations on the resulted file with types. For example, you may want to format it with tool of your choice or prepend code with a warning like "// The file was autogenerated, don't edit it manually". To add such a warning you can already use the built-in extension:
170
165
171
166
```diff
172
-
$application->add(
173
-
new ConvertCommand(
174
-
new Converter([
175
-
new DtoVisitor(new PhpAttributeFilter('Dto')),
176
-
]),
177
-
new TypeScriptGenerator(
178
-
new SingleFileOutputWriter('generated.ts'),
179
-
[
180
-
new DateTimeTypeResolver(),
181
-
new ClassNameTypeResolver(),
182
-
],
183
-
+ new OutputFilesProcessor([
184
-
+ new PrependAutogeneratedNoticeFileProcessor(),
185
-
+ ]),
186
-
),
187
-
new Filesystem(),
188
-
new OutputDiffCalculator(),
189
-
new FileSystemCodeProvider('/\.php$/'),
190
-
)
191
-
);
167
+
return static function (PhpConverterConfig $config) {
Feel free to create your own processor based on [PrependAutogeneratedNoticeFileProcessor](https://github.com/riverwaysoft/php-converter/blob/26ee25f07ac97a942e1327165424fc65777b80b0/src/OutputWriter/OutputProcessor/PrependAutogeneratedNoticeFileProcessor.php) source.
@@ -226,27 +217,23 @@ class PrettierFormatProcessor implements SingleOutputFileProcessorInterface
226
217
Then add it to the list:
227
218
228
219
```diff
229
-
$application->add(
230
-
new ConvertCommand(
231
-
new Converter([
232
-
new DtoVisitor(new PhpAttributeFilter('Dto')),
233
-
]),
234
-
new TypeScriptGenerator(
235
-
new SingleFileOutputWriter('generated.ts'),
236
-
[
237
-
new DateTimeTypeResolver(),
238
-
new ClassNameTypeResolver(),
239
-
],
240
-
+ new OutputFilesProcessor([
241
-
+ new PrependAutogeneratedNoticeFileProcessor(),
242
-
+ new PrettierFormatProcessor(),
243
-
+ ]),
244
-
),
245
-
new Filesystem(),
246
-
new OutputDiffCalculator(),
247
-
new FileSystemCodeProvider('/\.php$/'),
248
-
)
249
-
);
220
+
return static function (PhpConverterConfig $config) {
- Unlike [spatie/typescript-transformer](https://github.com/spatie/typescript-transformer)`php-converter` supports not only TypeScript but also Dart. Support for other languages can be easily added by implementing LanguageInterface. `php-converter` can also output generated types / classes into different files.
293
280
- Unlike [grpc](https://github.com/grpc/grpc/tree/v1.40.0/examples/php)`php-converter` doesn't require to modify your app or install some extensions.
294
281
282
+
## Phar installation
283
+
284
+
PHAR files, similar to JAR files in Java, bundle a PHP application and its dependencies into a single file. This provides the isolation of dependencies. Each PHAR can include its specific version of dependencies, avoiding conflicts with other packages on the same project. To download `phar` version of this package go to releases and download the `.phar` file from there. Static analyzers like PHPStan will complain if you use classes from the PHAR in your code, so you'd need to tell a static analyzer where to find these classes. Example for PHPStan:
0 commit comments