|
| 1 | +--- |
| 2 | +title: Environment Files |
| 3 | +order: 400 |
| 4 | +--- |
| 5 | + |
| 6 | +# Environment Files |
| 7 | + |
| 8 | +When NativePHP bundles your application, it will copy your entire application directory into the bundle, including your `.env` |
| 9 | +file. This means that your `.env` file will be accessible to anyone who has access to your application bundle. |
| 10 | + |
| 11 | +You should be careful to not include any sensitive information in your `.env` file, such as API keys or passwords. |
| 12 | +Unlike a traditional web application, your `.env` file can be read by anyone who has access to your application bundle. |
| 13 | + |
| 14 | +If you need to perform any sensitive operations, such as accessing an API or database, you should do so using a |
| 15 | +separate API that you create specifically for your application. You can then call this API from your application and |
| 16 | +have it perform the sensitive operations on your behalf. |
| 17 | + |
| 18 | +## Removing sensitive data from your environment files |
| 19 | + |
| 20 | +There are certain environment variables that NativePHP uses internally, for example to configure your application's |
| 21 | +updater, or Apple's notarization service. |
| 22 | + |
| 23 | +These environment variables are automatically removed from your `.env` file when your application is bundled, so you |
| 24 | +don't need to worry about them being exposed. |
| 25 | + |
| 26 | +If you want to remove other environment variables from your `.env` file, you can do so by adding them to the |
| 27 | +`cleanup_env_keys` configuration option in your `nativephp.php` config file: |
| 28 | + |
| 29 | +```php |
| 30 | + /** |
| 31 | + * A list of environment keys that should be removed from the |
| 32 | + * .env file when the application is bundled for production. |
| 33 | + * You may use wildcards to match multiple keys. |
| 34 | + */ |
| 35 | + 'cleanup_env_keys' => [ |
| 36 | + 'AWS_*', |
| 37 | + 'DO_SPACES_*', |
| 38 | + '*_SECRET', |
| 39 | + 'NATIVEPHP_UPDATER_PATH', |
| 40 | + 'NATIVEPHP_APPLE_ID', |
| 41 | + 'NATIVEPHP_APPLE_ID_PASS', |
| 42 | + 'NATIVEPHP_APPLE_TEAM_ID', |
| 43 | + ], |
| 44 | +``` |
0 commit comments