---
title: "Local Development: PHP"
description: "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."
canonical_url: "https://docs.ennote.io/guides/local-development/php"
---
# 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`](https://docs.ennote.io/cli/commands/config), or add `--organization-id` and `--workspace-id` flags as in the [overview](https://docs.ennote.io/guides/local-development/overview#sharing-the-command-with-your-team).

## Laravel

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

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

```bash
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.

<warning>

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`.

</warning>

## Symfony

Start the PHP built-in server through Ennote:

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

Console commands work the same way:

```bash
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.

```dotenv [.env]
APP_ENV=dev
DATABASE_URL=
STRIPE_SECRET_KEY=
```

## Plain PHP

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

Read values with `getenv()`:

```php [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:

```json [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>



</need-help>


## Sitemap

See the full [sitemap](https://docs.ennote.io/sitemap.md) for all pages.
