setup.php
Full Configuration Reference

You can add any php script by make setup.php by follow rules.

This guide documents every supported array key and option in a setup.php file. Use it to define how your app is installed and configured.

๐Ÿ“ File Structure

script_path/
โ””โ”€โ”€ app_name/
    โ”œโ”€โ”€ setup.php
    โ”œโ”€โ”€ database.sql
    โ””โ”€โ”€ index.php

1. database_info

Defines the SQL import file and the default table prefix.

"database_info" => array(
  "db_file" => "/wordpress/database.sql",
  "default_prefix" => "wp_",
  "default_prefix_change_able" => 1
)

2. database_replace

String replacements in SQL content before import.

"database_replace" => array(
  "[[timestamp]]" => "{{timestamp}}",
  "[[siteURL]]" => "{{siteURL}}",
  "[[date_now]]" => "{{date_now}}"
)
  • Replaces hardcoded tokens like [[timestamp]] in the SQL file with actual dynamic values.

3. database

Updates values inside your database after SQL import.

array(
  "table" => "{{tablePrefix}}options",
  "column" => "option_value",
  "where" => "option_name='siteurl'",
  "value" => "{{siteURL}}",
  "type" => "plain"
)
  • type: plain (text) or BCRYPT (secure hash)

4. create_file

Creates new files during installation.

"create_file" => array(
  array(
    "file_name" => ".htaccess",
    "type" => "create",
    "location" => "root",
    "content" => "<IfModule mod_rewrite.c> ..."
  )
)
  • location: Where to place the file. Usually root.
  • Use {{}} variables inside content dynamically.

5. change_file

Edits existing files, either directly or based on sample templates.

"change_file" => array(
  array(
    "file_name" => "wp-config.php",
    "sample_file_name" => "wp-config-sample.php",
    "location" => "root",
    "replace_map" => array(
      "database_name_here" => "{{dbName}}",
      "'wp_'" => "'{{tablePrefix}}'"
    )
  )
)

6. move

Moves extracted folders to the install location.

Fixed name:
"move" => array(
  array(
    "move" => 1,
    "source_path" => "upload"
  )
)
Wildcard pattern:
"move" => array(
  array(
    "move" => 1,
    "source_path_pattern" => "phpBB*"
  )
)

7. download

Specifies the source of the app zip.

"download" => array(
  "url" => "https://wordpress.org/latest.zip",
  "target_name" => "latest.zip",
  "ext" => "zip",
  "type" => "remote" // or "localhost"
)

8. extract

Used when you manually manage a ZIP file and want to extract it.

"extract" => array(
  "target_name" => "prestashop.zip",
  "ext" => "zip"
)

9. delete

Deletes folders or files after installation.

"delete" => array(
  array("path" => "install")
)

๐Ÿงฉ Supported Variables

  • {{dbName}}, {{dbUser}}, {{dbPass}}, {{dbHost}}
  • {{siteTitle}}, {{siteDesc}}, {{siteURL}}, {{siteDomain}}
  • {{adminUser}}, {{adminPass}}, {{adminEmail}}
  • {{rewriteBase}}, {{tablePrefix}}, {{install_path}}
  • {{timestamp}}, {{date_now}}, {{time_now}}

๐Ÿงช Example: WordPress setup.php

<?php

return array(
    "database_info" => array(
        
            "db_file" => "/wordpress/database.sql",
            "default_prefix" => "wp_",
            "default_prefix_change_able" =>1
            
       
    ),   
    "database" => array(
        array(
            "table" => "{{tablePrefix}}options",
            "column" => "option_value",
            "where" => "option_name='blogname'",
            "value" => "{{siteTitle}}",
            "type" => "plain"
        ),
        
    array(
        "table" => "{{tablePrefix}}options",
        "column" => "option_value",
        "where" => "option_name='blogdescription'",
        "value" => "{{siteDesc}}",
        "type" => "plain"
    ),
        array(
            "table" => "{{tablePrefix}}options",
            "column" => "option_value",
            "where" => "option_name='siteurl'",
            "value" => "{{siteURL}}",
            "type" => "plain"
        ),
        array(
            "table" => "{{tablePrefix}}options",
            "column" => "option_value",
            "where" => "option_name='home'",
            "value" => "{{siteURL}}",
            "type" => "plain"
        ),
        array(
            "table" => "{{tablePrefix}}options",
            "column" => "option_value",
            "where" => "option_name='admin_email'",
            "value" => "{{adminEmail}}",
            "type" => "plain"
        ),
        array(
            "table" => "{{tablePrefix}}users",
            "column" => "user_login",
            "where" => "ID=1",
            "value" => "{{adminUser}}",
            "type" => "plain"
        ),
        array(
            "table" => "{{tablePrefix}}users",
            "column" => "user_pass",
            "where" => "ID=1",
            "value" => "{{adminPass}}",
            "type" => "BCRYPT"
        ),
        array(
            "table" => "{{tablePrefix}}users",
            "column" => "user_email",
            "where" => "ID=1",
            "value" => "{{adminEmail}}",
            "type" => "plain"
        )
    ),

   "create_file" => array(
    array(
        "file_name" => ".htaccess",
        "type" => "create",
        "location" => "root",
        "content" => <<
RewriteEngine On
RewriteBase {{rewriteBase}}
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . {{rewriteBase}}/index.php [L]

# END WordPress
HTACCESS
    ),
    array(
        "file_name" => "olsapp.txt",
        "type" => "create",
        "location" => "root",
        "content" => << array(
        array(
            "file_name" => "wp-config.php",
            "sample_file_name" => "wp-config-sample.php",
            "location" => "root",
            "replace_map" => array(
                "database_name_here" => "{{dbName}}",
                "username_here" => "{{dbUser}}",
                "password_here" => "{{dbPass}}",
                "localhost" => "{{dbHost}}",
                "'wp_'" => "'{{tablePrefix}}'"
            )
        ),
        // Add more file rules here if needed
    ),
    
 "move" => array(
        array(
            "move" => 1,
            "source_path" => "wordpress",
            
        ),
        // Add more file rules here if needed
    ),
    
 "download" => array(
        
            "url" => "https://wordpress.org/latest.zip",
            "target_name" => "latest.zip",
            "ext" => "zip",
            "type" => "remote",
            
       
    )      
    
);