Skip to main content

Unattended Setup Mode

The PostCreateScript supports unattended (non-interactive) setup via a JSON configuration file.

How It Works​

  1. Place a setup.json file in one of the supported locations (see below)
  2. Run composer create-project
  3. The setup script will detect the file and run in unattended mode
  4. The setup.json file remains for reuse across multiple projects

Configuration File Locations​

The script searches for setup.json in the following locations (in priority order):

1. Environment Variable (Highest Priority)​

Use the SETUP_JSON environment variable to specify a custom location:

SETUP_JSON=/path/to/custom-setup.json composer create-project byjg/gluo my-project ^7.0

Use cases:

  • Custom configuration locations
  • CI/CD pipelines with specific configs
  • Temporary overrides for specific projects

When SETUP_JSON is set, the file must exist where Composer runs, or the setup stops with an error. A Composer that runs in a container (a composer wrapper around docker run, for instance) only sees the directories mounted into it, usually just the current one: put the file there, or mount its directory.

2. Parent Directory​

The script looks in the directory where you run the composer create-project command:

/home/user/projects/setup.json # ← Config file here
/home/user/projects/my-project/ # ← New project created here

Use cases:

  • Project-specific configurations
  • Quick one-off setups
  • When you want config alongside projects

The script checks your home directory:

Linux/Mac:

~/.gluo/setup.json

Windows:

C:\Users\YourName\.gluo\setup.json

Use cases:

  • Personal default configurations
  • Settings you want to reuse for all projects
  • Keep your workspace clean

Setup Examples​

Example 1: Personal Defaults in Home Directory​

Create your personal defaults once:

# Linux/Mac
mkdir -p ~/.gluo
cat > ~/.gluo/setup.json << 'EOF'
{
"timezone": "America/Toronto",
"install_frontend": true,
"install_examples": false
}
EOF

# Now create projects anywhere - they'll use your defaults
cd ~/projects
composer create-project byjg/gluo project1 ^7.0
composer create-project byjg/gluo project2 ^7.0

Example 2: Parent Directory (Quick Setup)​

# Create config in your projects directory
cd ~/projects
cat > setup.json << 'EOF'
{
"namespace": "MyApp",
"composer_name": "mycompany/myapp",
"install_frontend": true,
"install_examples": false
}
EOF

# Create project in the same directory
composer create-project byjg/gluo my-project ^7.0

Example 3: Environment Variable (CI/CD)​

# Store config anywhere
cat > /etc/ci-configs/rest-setup.json << 'EOF'
{
"namespace": "AutoDeployApp",
"install_frontend": true,
"install_examples": false
}
EOF

# Use it with environment variable
SETUP_JSON=/etc/ci-configs/rest-setup.json composer create-project byjg/gluo production-app ^7.0

Configuration Options​

FieldTypeDefaultDescription
php_versionstringCurrent PHP versionPHP version (8.3, 8.4, 8.5, 8.6)
namespacestring"MyRest"Project namespace (CamelCase)
composer_namestring"me/myrest"Composer package name (vendor/package)
db_schemastringmysqlOne of: mysql, postgres, sqlite
db_hoststringgluo-databaseDatabase host/service (ignored for SQLite)
db_userstringroot / postgresDatabase username (ignored for SQLite)
db_passwordstringmysqlp455w0rdDatabase password (ignored for SQLite)
db_name_devstringlocaldevDevelopment database/schema name
db_name_teststringlocaltestTest database/schema name
timezonestring"UTC"Server timezone
install_frontendbooleantrueInclude the frontend/ Vite app (login, reset, dashboard, profile)
install_examplesbooleantrueInclude example code (Project/Task/Note + Sample; frontend example screens)

Legacy compatibility: The older mysql_connection field is still accepted. When present, it will be parsed and used to populate the new database fields automatically, but it is recommended to migrate to the explicit settings above for clarity and to support other drivers.

All Fields Are Optional​

If a field is not provided in setup.json, the default value will be used. You can provide only the fields you want to customize:

{
"namespace": "MyCustomApp",
"composer_name": "company/custom-app",
"install_frontend": true,
"install_examples": false
}

Errors​

A setup.json that is found but is not a valid JSON object stops the setup with an error naming the file, instead of falling back to the questions with the default answers.

Priority Order​

When multiple setup.json files exist, the script uses the first one found:

  1. ✅ SETUP_JSON environment variable → Highest priority
  2. ✅ Parent directory ../setup.json
  3. ✅ Home directory ~/.gluo/setup.json

Example: If you have both a home directory config and use SETUP_JSON, the environment variable wins.

Docker Warning in Unattended Mode​

If Docker is not installed, the warning will be displayed, but the setup will continue automatically without waiting for user input.

When Composer itself runs inside a container, it cannot see the host's Docker, so the setup prints a note that Docker could not be checked instead of the warning, and does not wait for input.

Interactive Mode​

If setup.json does not exist, the setup runs in interactive mode (default behavior) and prompts for all configuration values.

Security Note​

The setup.json file is listed in .gitignore to prevent accidentally committing it to version control. If it contains sensitive information, consider adding it to your global gitignore as well.