Unattended Setup Mode
The PostCreateScript supports unattended (non-interactive) setup via a JSON configuration file.
How It Works
- Place a
setup.jsonfile in one of the supported locations (see below) - Run
composer create-project - The setup script will detect the file and run in unattended mode
- The
setup.jsonfile 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
3. User Home Directory (Recommended for Personal Defaults)
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
| Field | Type | Default | Description |
|---|---|---|---|
php_version | string | Current PHP version | PHP version (8.3, 8.4, 8.5, 8.6) |
namespace | string | "MyRest" | Project namespace (CamelCase) |
composer_name | string | "me/myrest" | Composer package name (vendor/package) |
db_schema | string | mysql | One of: mysql, postgres, sqlite |
db_host | string | gluo-database | Database host/service (ignored for SQLite) |
db_user | string | root / postgres | Database username (ignored for SQLite) |
db_password | string | mysqlp455w0rd | Database password (ignored for SQLite) |
db_name_dev | string | localdev | Development database/schema name |
db_name_test | string | localtest | Test database/schema name |
timezone | string | "UTC" | Server timezone |
install_frontend | boolean | true | Include the frontend/ Vite app (login, reset, dashboard, profile) |
install_examples | boolean | true | Include example code (Project/Task/Note + Sample; frontend example screens) |
Legacy compatibility: The older
mysql_connectionfield 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:
- ✅
SETUP_JSONenvironment variable → Highest priority - ✅ Parent directory
../setup.json - ✅ 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.