Skip to content

Commit

Permalink
upgrade configuration docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed May 24, 2024
1 parent 0d8dc45 commit cab6c90
Showing 1 changed file with 57 additions and 46 deletions.
103 changes: 57 additions & 46 deletions content/documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ These are all Phel specific configuration options available, along with the valu
<?php
// phel-config.php
return (new \Phel\Config\PhelConfig())
->setSrcDirs(['src/phel'])
->setTestDirs(['tests/phel'])
->setSrcDirs(['src'])
->setTestDirs(['tests'])
->setVendorDir('vendor')
->setOut((new PhelOutConfig())
->setMainPhelNamespace('your-ns\main')
->setMainPhpPath('out/main.php'))
->setExport((new \Phel\Config\PhelExportConfig())
->setDirectories(['src/phel'])
->setNamespacePrefix('PhelGenerated')
->setTargetDirectory('src/PhelGenerated'))
->setIgnoreWhenBuilding(['src/phel/local.phel'])
->setNoCacheWhenBuilding(['src/phel/local.phel'])
->setErrorLogFile('data/error.log')
->setIgnoreWhenBuilding(['ignore-when-building.phel'])
->setNoCacheWhenBuilding([])
->setFormatDirs(['src', 'tests'])
->setKeepGeneratedTempFiles(false)
->setBuildConfig((new \Phel\Config\PhelBuildConfig())
->setMainPhelNamespace('your-ns\index')
->setMainPhpPath('out/index.php'))
->setExportConfig((new \Phel\Config\PhelExportConfig())
->setFromDirectories(['src'])
->setNamespacePrefix('PhelGenerated')
->setTargetDirectory('src/PhelGenerated'))
;
```

Expand All @@ -41,7 +42,7 @@ Set a list of directories in which the source files for the project are located.
```php
<?php
return (new \Phel\Config\PhelConfig())
->setSrcDirs(['src/phel'])
->setSrcDirs(['src'])
# ...
;
```
Expand All @@ -53,14 +54,14 @@ Set a list of directories in which the test files are located.
```php
<?php
return (new \Phel\Config\PhelConfig())
->setTestDirs(['tests/phel'])
->setTestDirs(['tests'])
# ...
;
```

### VendorDir

Set the name of the composer vendor directory. Default is `vendor`.
Set the name of the composer vendor directory.

```php
<?php
Expand All @@ -70,92 +71,102 @@ return (new \Phel\Config\PhelConfig())
;
```

### OutConfig
### ErrorLogFile

The configuration when running the `phel build` command.
Set the path to the `error.log` file

```php
<?php
return (new \Phel\Config\PhelConfig())
->setOut((new PhelOutConfig())
->setMainPhelNamespace('your-ns\main')
->setMainPhpPath('out/main.php'))
->setErrorLogFile('data/error.log')
# ...
;
```

- `setMainPhelNamespace`: the main phel namespace to start transpiling the Phel code.
- `setMainPhpPath`: the entry point of the build PHP result.
### IgnoreWhenBuilding

### ExportConfig
Set a list of Phel files that should be ignored when building the code.

Set configuration options that are being used for the `phel export` command that is described in the [PHP Interop](/documentation/php-interop/#calling-phel-functions-from-php) chapter.

```php
<?php
return (new \Phel\Config\PhelConfig())
->setExport((new \Phel\Config\PhelExportConfig())
->setDirectories(['src/phel'])
->setNamespacePrefix('PhelGenerated')
->setTargetDirectory('src/PhelGenerated'))
->setIgnoreWhenBuilding(['ignore-when-building.phel'])
# ...
;
```

Currently, the export command requires three options:
### NoCacheWhenBuilding

- `setDirectories`: Sets a list of directories in which the export command should search for export functions.
- `setNamespacePrefix`: Sets a namespace prefix for all generated PHP classes.
- `setTargetDirectory`: Sets the directory where the generated PHP classes are stored.
Set a list of Phel files that should be not cached when building the code. This means, they will be transpiled all the time; regardless when you use the `--cache` or `--no-cache` flag.

### IgnoreWhenBuilding
```php
<?php
return (new \Phel\Config\PhelConfig())
->setNoCacheWhenBuilding([])
# ...
;
```

Set a list of Phel files that should be ignored when building the code.
### FormatDirs

Set a list of directories whose files will be formatted when running the format command.


```php
<?php
return (new \Phel\Config\PhelConfig())
->setIgnoreWhenBuilding(['src/phel/local.phel'])
->setFormatDirs(['src', 'tests'])
# ...
;
```

### NoCacheWhenBuilding

- `setNoCacheWhenBuilding(list<string>)`
### KeepGeneratedTempFiles

Set a list of Phel files that should be not cached when building the code. This means, they will be transpiled all the time; regardless when you use the `--cache` or `--no-cache` flag.
A flag that automatically removes all generated temporal files once the command `phel run` has been executed. Default is `false`.

```php
<?php
return (new \Phel\Config\PhelConfig())
->setNoCacheWhenBuilding(['src/phel/local.phel'])
->setKeepGeneratedTempFiles(false)
# ...
;
```

### FormatDirs

Set a list of directories whose files will be formatted when running the format command.
### BuildConfig

The configuration when running the `phel build` command.

```php
<?php
return (new \Phel\Config\PhelConfig())
->setFormatDirs(['src', 'tests'])
->setOut((new PhelBuildConfig())
->setMainPhelNamespace('your-ns\index')
->setMainPhpPath('out/index.php'))
# ...
;
```

### KeepGeneratedTempFiles
- `setMainPhelNamespace`: the main phel namespace to start transpiling the Phel code.
- `setMainPhpPath`: the entry point of the build PHP result.

A flag that automatically removes all generated temporal files once the command `phel run` has been executed. Default is `false`.
### ExportConfig

Set configuration options that are being used for the `phel export` command that is described in the [PHP Interop](/documentation/php-interop/#calling-phel-functions-from-php) chapter.

```php
<?php
return (new \Phel\Config\PhelConfig())
->setKeepGeneratedTempFiles(false)
->setExport((new \Phel\Config\PhelExportConfig())
->setFromDirectories(['src'])
->setNamespacePrefix('PhelGenerated')
->setTargetDirectory('src/PhelGenerated'))
# ...
;
```

Currently, the export command requires three options:

- `setFromDirectories`: Sets a list of directories in which the export command should search for export functions.
- `setNamespacePrefix`: Sets a namespace prefix for all generated PHP classes.
- `setTargetDirectory`: Sets the directory where the generated PHP classes are stored.

0 comments on commit cab6c90

Please sign in to comment.