Local Development

Local Development: PHP

Run Laravel, Symfony and plain PHP apps locally with secrets from Ennote instead of a .env file, by starting php artisan serve, the PHP built-in server or Composer scripts with ennote secret get.

Put ennote secret get "<secret>" -- in front of the command that starts your app. PHP reads the values as environment variables, and both Laravel and Symfony give real environment variables priority over .env files.

The examples use a secret named api-env. Set your organization and workspace once with ennote config set, or add --organization-id and --workspace-id flags as in the overview.

Laravel

ennote secret get "api-env" -- php artisan serve

Artisan commands that need the same values run the same way:

ennote secret get "api-env" -- php artisan migrate
ennote secret get "api-env" -- php artisan queue:work
ennote secret get "api-env" -- php artisan tinker

Name the keys of your Ennote secret exactly like the variables in .env: APP_KEY, DB_PASSWORD, MAIL_PASSWORD. Your config/*.php files read them with env() as before. Laravel does not override variables that are already set, so the values from Ennote win, and it starts without a .env file.

Do not run php artisan config:cache in local development. A cached configuration stores the values that were set when you ran it, in a plain-text file under bootstrap/cache/, and ignores the environment from then on. If you cached it earlier, run php artisan config:clear.

Symfony

Start the PHP built-in server through Ennote:

ennote secret get "api-env" -- php -S 127.0.0.1:8000 -t public

Console commands work the same way:

ennote secret get "api-env" -- php bin/console doctrine:migrations:migrate

Symfony expects a .env file to exist. Keep the committed .env with non-secret defaults and empty placeholders, for example DATABASE_URL=, and delete .env.local with your real values. Real environment variables always take precedence over .env files, so the values from Ennote win.

.env
APP_ENV=dev
DATABASE_URL=
STRIPE_SECRET_KEY=

Plain PHP

ennote secret get "api-env" -- php -S 127.0.0.1:8000 -t public

Read values with getenv():

config.php
$databaseUrl = getenv('DATABASE_URL');
if ($databaseUrl === false) {
    throw new RuntimeException('DATABASE_URL is not set');
}

$_ENV is often empty because many php.ini files set variables_order without E. Use getenv() or $_SERVER instead. If you use vlucas/phpdotenv, its immutable loaders (Dotenv::createImmutable) do not override variables that are already set.

Saving the Command in composer.json

Add Composer scripts so the whole team runs the same command:

composer.json
{
  "scripts": {
    "dev": [
      "Composer\\Config::disableProcessTimeout",
      "ennote secret get \"api-env\" --organization-id \"my-org-id\" --workspace-id \"local-development\" -- php artisan serve"
    ],
    "migrate": "ennote secret get \"api-env\" -- php artisan migrate"
  }
}

Run composer dev or composer migrate. Composer\Config::disableProcessTimeout stops Composer from killing the dev server after its default 300-second script timeout.

Need Help?

If you encounter any issues or have questions, don't hesitate to contact support. Our team is here to assist you with any challenges you might face.