Framework Integration
Use phase run to inject secrets into your application process at runtime. No code changes or dependencies required.
Prerequisites
- Create an account on the Phase Console
- Install the CLI
Initialize Phase
In the root of your application's codebase run:
phase init
Next.js
phase run npm run dev
Alternatively, you can use phase run in your package.json file, so secrets will automatically be injected when you npm run dev.
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "phase run next dev",
"build": "next build && next export",
"start": "next start",
"lint": "next lint"
}
}
Note that for environment variables to be exposed to the client, you'll have
to prefix them with NEXT_PUBLIC_. Read more about that
here.
Node.js
phase run npm run dev
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
}
}
React
phase run npm start
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "phase run react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
}
REACT_APP_Django
phase run python manage.py runserver payments-api:8000
Chaining multiple commands
phase run "python manage.py migrate && python manage.py runserver payments-api:8000"
Nuxt
phase run npm run dev
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "phase run nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
}
}
NestJS
phase run npm run start:dev
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"private": true,
"scripts": {
"start:dev": "phase run nest start --watch",
"start": "nest start",
"start:prod": "node dist/main"
}
}
Vue.js
phase run npm run dev
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "phase run vue-cli-service serve",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
}
}
Vue.js client side environment variables must be prefixed with VUE_APP
FastAPI
phase run uvicorn main:app --reload
Flask
phase run flask run
Svelte
phase run npm run dev
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "phase run \"run-s build:env:prod build:sveltekit build:env:local\"",
"dev": "phase run \"npm run check-env && npm run dev:sveltekit\""
}
}
Svelte client side environment variables must be prefixed with PUBLIC_
Fiber
phase run go run server.go
Ruby on Rails
phase run rails server
Laravel
Development Environment
phase run php artisan serve
Production Environment
In production, Laravel applications typically run using PHP-FPM managed by supervisor. PHP-FPM can read environment variables from the host system when properly configured.
Configure PHP-FPM
Ensure your PHP-FPM pool configuration preserves environment variables:
; In your PHP-FPM pool configuration (e.g., www.conf)
clear_env = no
Configure Supervisor
Set up supervisor to run PHP-FPM through Phase:
[program:laravel]
process_name=%(program_name)s_%(process_num)02d
command=phase run php-fpm
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel.log
Gatsby
phase run npm run dev
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "phase run \"gatsby build\"",
"dev": "phase run \"gatsby develop\""
}
}
Gatsby client side environment variables must be prefixed with GATSBY_
Remix
phase run npm run dev
package.json:
{
"name": "McLaren",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "phase run \"remix build\"",
"dev": "phase run \"remix dev\""
}
}
.NET
phase run dotnet run