Skip to content

Commit 451413a

Browse files
shanerbaner82claude
andcommitted
docs(mobile): document that PHP source ships readable in the app package
Add 'Your code ships with your app' section to the v3/v4 security pages explaining the security model (bundled source is readable, encryption would be theater, keep secrets server-side, use cleanup_env_keys), and clarify on the v3/v4 configuration pages that the R8/ProGuard build options only affect Kotlin/Java, not the bundled PHP. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b23e2ca commit 451413a

4 files changed

Lines changed: 58 additions & 2 deletions

File tree

‎resources/views/docs/mobile/3/concepts/security.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@ order: 100
88
Although NativePHP tries to make it as easy as possible to make your application secure, it is your responsibility to
99
protect your users.
1010

11+
### Your code ships with your app
12+
13+
When you build your app for release, your Laravel application — PHP source, views, and assets — is bundled into the
14+
app package (APK/AAB on Android, IPA on iOS) and extracted on the device the first time your app runs. The device
15+
needs this code to run your app, so anyone who unpacks your app package can read it.
16+
17+
This is true of every mobile app, whatever it's built with: JavaScript ships the same way in React Native and Ionic
18+
apps, and even compiled Kotlin and Swift can be decompiled. Android's
19+
[minification and obfuscation options](../getting-started/configuration#android-build-configuration) apply R8/ProGuard
20+
to the app's Kotlin/Java code only; your PHP is bundled as an asset and ships as written.
21+
22+
Encrypting the bundle wouldn't change this: the decryption key would have to ship inside the same package, where it
23+
can be extracted just as easily. Rather than trying to hide client-side code, build so that reading it doesn't matter:
24+
25+
- Treat everything you bundle as public — your PHP source, views, and the parts of your `.env` file that ship with
26+
the app.
27+
- Keep secrets and sensitive business logic on a server, behind authenticated APIs.
28+
- Strip sensitive keys from your bundled `.env` using the `cleanup_env_keys` option in `config/nativephp.php` — see
29+
[Configuration](../getting-started/configuration).
30+
31+
The rest of this page covers how to handle the data that genuinely needs protecting: secrets, tokens, and your users'
32+
data on the device.
33+
1134
### Secrets and .env
1235

1336
As your application is being installed on systems outside your/your organisation's control, it is important to think

‎resources/views/docs/mobile/3/getting-started/configuration.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Fine-tune your Android build process with these options under the `android.build
230230

231231
- `minify_enabled` — Enable R8/ProGuard code shrinking. (default: `false`)
232232
- `shrink_resources` — Remove unused resources from the APK. (default: `false`)
233-
- `obfuscate` — Obfuscate class and method names. (default: `false`)
233+
- `obfuscate` — Obfuscate Kotlin/Java class and method names. (default: `false`)
234234
- `debug_symbols` — Include debug symbols. Set to `FULL` for symbolicated crash reports. (default: `FULL`)
235235
- `parallel_builds` / `incremental_builds` — Gradle build performance options. (default: `true`)
236236

@@ -241,6 +241,11 @@ reduce your APK size. Test thoroughly after enabling these options.
241241

242242
</aside>
243243

244+
The `minify_enabled`, `shrink_resources` and `obfuscate` options apply R8/ProGuard to the app's Kotlin/Java code.
245+
Your PHP application is bundled as an asset and ships as written — see
246+
[Security](../concepts/security#your-code-ships-with-your-app) for how to handle the code and secrets that
247+
ship with your app.
248+
244249
## Android Status Bar Style
245250

246251
Control the color of the status bar and navigation bar icons:

‎resources/views/docs/mobile/4/digging-deeper/security.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@ order: 100
88
Although NativePHP tries to make it as easy as possible to make your application secure, it is your responsibility to
99
protect your users.
1010

11+
### Your code ships with your app
12+
13+
When you build your app for release, your Laravel application — PHP source, views, and assets — is bundled into the
14+
app package (APK/AAB on Android, IPA on iOS) and extracted on the device the first time your app runs. The device
15+
needs this code to run your app, so anyone who unpacks your app package can read it.
16+
17+
This is true of every mobile app, whatever it's built with: JavaScript ships the same way in React Native and Ionic
18+
apps, and even compiled Kotlin and Swift can be decompiled. Android's
19+
[minification and obfuscation options](../getting-started/configuration#android-build-configuration) apply R8/ProGuard to
20+
the app's Kotlin/Java code only; your PHP is bundled as an asset and ships as written.
21+
22+
Encrypting the bundle wouldn't change this: the decryption key would have to ship inside the same package, where it
23+
can be extracted just as easily. Rather than trying to hide client-side code, build so that reading it doesn't matter:
24+
25+
- Treat everything you bundle as public — your PHP source, views, and the parts of your `.env` file that ship with
26+
the app.
27+
- Keep secrets and sensitive business logic on a server, behind authenticated APIs.
28+
- Strip sensitive keys from your bundled `.env` using the `cleanup_env_keys` option in `config/nativephp.php` — see
29+
[Configuration](../getting-started/configuration).
30+
31+
The rest of this page covers how to handle the data that genuinely needs protecting: secrets, tokens, and your users'
32+
data on the device.
33+
1134
### Secrets and .env
1235

1336
As your application is being installed on systems outside your/your organisation's control, it is important to think

‎resources/views/docs/mobile/4/getting-started/configuration.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Fine-tune your Android build process with these options under the `android.build
230230

231231
- `minify_enabled` — Enable R8/ProGuard code shrinking. (default: `false`)
232232
- `shrink_resources` — Remove unused resources from the APK. (default: `false`)
233-
- `obfuscate` — Obfuscate class and method names. (default: `false`)
233+
- `obfuscate` — Obfuscate Kotlin/Java class and method names. (default: `false`)
234234
- `debug_symbols` — Include debug symbols. Set to `FULL` for symbolicated crash reports. (default: `FULL`)
235235
- `parallel_builds` / `incremental_builds` — Gradle build performance options. (default: `true`)
236236

@@ -241,6 +241,11 @@ reduce your APK size. Test thoroughly after enabling these options.
241241

242242
</aside>
243243

244+
The `minify_enabled`, `shrink_resources` and `obfuscate` options apply R8/ProGuard to the app's Kotlin/Java code.
245+
Your PHP application is bundled as an asset and ships as written — see
246+
[Security](../digging-deeper/security#your-code-ships-with-your-app) for how to handle the code and secrets that
247+
ship with your app.
248+
244249
## Android Status Bar Style
245250

246251
Control the color of the status bar and navigation bar icons:

0 commit comments

Comments
 (0)