Documentation Index
Fetch the complete documentation index at: https://docs.n3wmedia.com/llms.txt
Use this file to discover all available pages before exploring further.
Environment Configuration
FrankPHP can now adopt a more standard.env-based configuration approach for credentials and environment-specific settings.
This is a worthwhile step for two reasons.
First, it improves security by keeping sensitive values out of general configuration files that are more likely to be copied, reused, or accidentally distributed. Second, it makes FrankPHP feel more familiar to developers coming from other modern PHP frameworks.
That does not mean FrankPHP needs to become dependency-heavy or over-engineered. The goal is still the same: explicit, readable configuration with no unnecessary complexity.
Why use a .env file?
A .env file gives you one place to keep environment-specific values such as:
- database host
- database name
- database username
- database password
- mail credentials
- app environment flags
- timezone overrides
- local development
- staging
- production
- customer-specific installations
The security advantage
The biggest practical advantage is simple: sensitive credentials are less likely to be exposed accidentally. Without a dedicated.env approach, there is a tendency to place secrets directly in Config/config.php or other framework files. That works, but it increases the chance that credentials are:
- copied into a release package
- committed into source history
- shared during support/debugging
- left in files that are reused as templates
.env file reduces that risk.
Why this aligns FrankPHP with other PHP frameworks
Most major PHP frameworks now separate environment-specific secrets from framework configuration. That is not just a convention for convention’s sake. It solves a real operational problem: credentials and runtime settings change by environment, while framework code should remain stable. Moving FrankPHP toward a standard.env pattern makes the framework more familiar to developers coming from the broader PHP ecosystem, while still preserving the FrankPHP philosophy of explicit code and minimal moving parts.
Recommended file setup
A practical setup looks like this:.env
Contains real credentials and environment-specific values.
Example:
.env.example
Contains the same keys but with placeholder values.
This file can be distributed in the customer Zip because it acts as the setup template.
Example:
The real
.env file should normally stay local to the server or development machine. The .env.example file is what you ship.How FrankPHP should use it
The exact implementation can stay simple. FrankPHP does not need a third-party environment package to get the core benefit. A small internal loader can:- read the
.envfile if it exists - parse
KEY=valuelines - place the values into
$_ENVor a simple lookup array - let
Config/config.phpread from those values
What changes in practice
Instead of hardcoding credentials inConfig/config.php, that file becomes a normal configuration layer that reads from environment values.
Conceptually, the responsibility changes like this:
.envholds secrets and environment-specific valuesConfig/config.phpmaps those values into the framework configuration array- the framework continues to read configuration in the usual way
Release packaging reminder
If you adopt.env, your release process should change slightly.
Do not include
.env
Safe to include
.env.example
.env automatically rather than relying on you to remember to delete it before creating the Zip.
How to use this in practice
If your framework has been updated to support.env, the normal workflow becomes:
Step 1: Copy the example file
Create a real.env based on the shipped template.
Step 2: Fill in the real credentials
Edit.env and add the correct values for the current environment.
Step 3: Leave Config/config.php as framework configuration
Avoid editing it repeatedly just to swap credentials between environments.
Step 4: Keep .env out of release packages
When building a Gumroad release, ship .env.example but exclude .env.
Suggested update to the installation guide
Ifget-frankphp-running.mdx still instructs users to open Config/config.php and place their database credentials directly inside it, that guide should be updated.
The setup flow should instead become:
- unzip FrankPHP
- copy
.env.exampleto.env - fill in database credentials there
- upload the framework
- ensure the web root points to
/public
Recommended wording for the setup guide
A revised setup section would say something like this:FrankPHP uses a simpleThat small change makes the installation process feel more modern while still staying simple..envfile for environment-specific settings such as database credentials. Copy.env.exampleto.env, then enter your database details there before uploading the framework.
Final reminder
The move to.env is not about adding complexity. It is about keeping sensitive values in the right place and making FrankPHP easier to work with across local, staging, and production environments.
Done properly, it gives you:
- better separation of secrets from framework code
- safer release packaging
- cleaner configuration management
- a setup process that feels familiar to PHP developers