@phpsandbox/cli 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +131 -0
  2. package/package.json +8 -8
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # PHPSandbox CLI
2
+
3
+ Create sandboxes, run commands, work with files and Git, and manage the sandbox lifecycle from your terminal. The CLI uses the [PHPSandbox SDK](https://github.com/phpsandbox/sdk) and the platform API, with progress output for provisioning and restoration, interactive shells, and JSON output for scripts.
4
+
5
+ ## Install
6
+
7
+ With Node.js 22 or newer:
8
+
9
+ ```sh
10
+ npm install --global @phpsandbox/cli@latest
11
+ phpsandbox --version
12
+ ```
13
+
14
+ Bun is not required to use the npm package. Keep npm's optional dependencies enabled: they provide the executable for your platform.
15
+
16
+ For an executable with no Node.js or Bun requirement, download a binary and its `.sha256` file from [GitHub Releases](https://github.com/phpsandbox/cli/releases). Available targets are macOS arm64/x64, Linux arm64/x64 with glibc or musl, and Windows x64.
17
+
18
+ On macOS or Linux, verify the checksum, make the file executable, rename it to `phpsandbox`, and place it in a directory on your `PATH`. For example, after downloading the macOS arm64 assets:
19
+
20
+ ```sh
21
+ shasum -a 256 -c phpsandbox-darwin-arm64.sha256
22
+ chmod +x phpsandbox-darwin-arm64
23
+ mkdir -p "$HOME/.local/bin"
24
+ mv phpsandbox-darwin-arm64 "$HOME/.local/bin/phpsandbox"
25
+ export PATH="$HOME/.local/bin:$PATH"
26
+ ```
27
+
28
+ On Windows, download `phpsandbox-windows-x64.exe`, compare `Get-FileHash -Algorithm SHA256` with its checksum file, rename it to `phpsandbox.exe`, and add its directory to your user `Path`.
29
+
30
+ ## Your first sandbox
31
+
32
+ Use a PHPSandbox API key with `read:notebook` and `write:notebook` permissions, and an account with SDK/API access. `auth login` prompts for an existing key and stores it in your operating system credential store.
33
+
34
+ ```sh
35
+ phpsandbox auth login
36
+ phpsandbox create --template standard --name first-sandbox
37
+ phpsandbox status
38
+ phpsandbox exec -- php -v
39
+ phpsandbox exec -- php -r 'echo "Hello from PHPSandbox\n";'
40
+ phpsandbox files list
41
+ phpsandbox open
42
+ ```
43
+
44
+ `create` waits for provisioning and selects the new sandbox. `open` opens its preview; use `open --print` to print the URL. Run `phpsandbox shell` for an interactive shell.
45
+
46
+ When you finish:
47
+
48
+ ```sh
49
+ phpsandbox stop # Keep the notebook; stop its runtime
50
+ phpsandbox ready # Start or restore it and wait until ready
51
+ phpsandbox delete # Permanently delete after confirmation
52
+ ```
53
+
54
+ For an existing sandbox, run `phpsandbox use SANDBOX_ID` in your project directory. This writes `.phpsandbox.json` with the sandbox ID and API endpoint. To target one command explicitly, use `--sandbox SANDBOX_ID`.
55
+
56
+ ## Explore
57
+
58
+ ```sh
59
+ phpsandbox --help
60
+ phpsandbox files --help
61
+ phpsandbox git checkpoint --help
62
+ phpsandbox list --json
63
+ ```
64
+
65
+ - [Command reference](https://github.com/phpsandbox/cli/blob/main/docs/commands.md): all commands, arguments, flags, and defaults, generated from the CLI.
66
+ - [Authentication, configuration, and CI](https://github.com/phpsandbox/cli/blob/main/docs/configuration.md): credentials, sandbox selection, output, automation, and troubleshooting.
67
+ - [Workflow guide](https://github.com/phpsandbox/cli/blob/main/docs/workflows.md): common tasks for running commands, transferring files, Git, and secrets.
68
+ - [Development guide](https://github.com/phpsandbox/cli/blob/main/docs/development.md): build, install locally, test against an API, regenerate documentation, and release.
69
+
70
+ ## Scripting
71
+
72
+ Provide your API key as `PHPSANDBOX_TOKEN` using your CI secret store. Add `--json` to commands that return structured data, and `--yes` to confirmed destructive operations. Remote `exec` commands preserve their exit code.
73
+
74
+ ```sh
75
+ phpsandbox exec --sandbox SANDBOX_ID --json -- php -v
76
+ phpsandbox delete SANDBOX_ID --yes --json
77
+ ```
78
+
79
+ Progress goes to stderr; JSON results go to stdout. Commands that follow logs or other streams emit JSON Lines with `--json`.
80
+
81
+ ## Publishing
82
+
83
+ Inspect your app and the destination before publishing:
84
+
85
+ ```sh
86
+ phpsandbox publication readiness
87
+ phpsandbox publication catalog ssh-server --server SERVER_ID
88
+ phpsandbox publication catalog laravel-cloud
89
+ phpsandbox publication catalog cloudflare-containers
90
+ phpsandbox publication plan publish.json
91
+ phpsandbox publish publish.json
92
+ ```
93
+
94
+ Use your connected server or provider account. The catalog returns the same resource choices as the publishing panel. Plans show missing settings and resource choices without creating resources. Publishing asks for confirmation; use `--yes` for scripts. For repository-based publishing, workspace changes are committed and pushed before deployment. Provider resources may incur charges.
95
+
96
+ For example, an SSH publishing file can create a separate production MySQL database:
97
+
98
+ ```json
99
+ {
100
+ "slug": "my-app",
101
+ "provider": { "name": "ssh-server", "serverId": "SERVER_ID" },
102
+ "resources": {
103
+ "database": { "mode": "create", "type": "mysql", "version": "8.4" },
104
+ "cache": { "mode": "none" },
105
+ "storage": { "mode": "none" },
106
+ "worker": { "mode": "none" },
107
+ "scheduler": { "mode": "none" }
108
+ }
109
+ }
110
+ ```
111
+
112
+ For Laravel Cloud, use `{"name":"laravel-cloud","region":"eu-central-1","setup":{"repositoryAccessConfirmed":true}}` as the provider. Choose resource types, sizes and configuration from its catalog. For Cloudflare Containers, use `{"name":"cloudflare-containers","accountId":"ACCOUNT_ID"}`. Cloudflare does not provision databases, caches or file storage through this integration. Declaring a resource `external` only records your choice; configure its connection separately in Production secrets.
113
+
114
+ ```sh
115
+ phpsandbox publish --yes # Publish changes with the existing setup
116
+ phpsandbox publication status --json
117
+ phpsandbox publication resources --json
118
+ phpsandbox publication build-logs
119
+ phpsandbox publication delete # Unpublish and retain resources
120
+ phpsandbox publication delete --delete-resources # Remove app-owned resources and their data
121
+ ```
122
+
123
+ Publishing follows progress and build logs by default. `--no-wait` returns after the publishing stream attaches; deployment continues on the server. Removing resources permanently deletes their data. Resources reused from elsewhere remain managed separately.
124
+
125
+ ### Live publishing tests
126
+
127
+ `bun run test:publications` exercises all three providers through the standalone executable: plan, publish, HTTP response, republish, unpublish and resource cleanup. It requires `PHPSANDBOX_API_URL`, `PHPSANDBOX_TOKEN`, `PHPSANDBOX_PUBLICATION_SOURCE` (a disposable app fixture), and `PHPSANDBOX_PUBLICATION_CONFIGS` (a JSON object with a publishing configuration for each provider name). Laravel Cloud also needs `PHPSANDBOX_PUBLICATION_GIT_TARGET`, the JSON Git target for a disposable repository and existing branch, including its author. Publishing can commit and push to that branch; do not use a production repository. Each test forks the source, attaches its existing provider connections, and cleans up the fork and app-owned publication resources even after a failure.
128
+
129
+ ## License
130
+
131
+ MIT.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.1",
2
+ "version": "0.3.0",
3
3
  "license": "MIT",
4
4
  "repository": {
5
5
  "type": "git",
@@ -21,12 +21,12 @@
21
21
  "node": ">=22"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@phpsandbox/cli-darwin-arm64": "0.1.1",
25
- "@phpsandbox/cli-darwin-x64": "0.1.1",
26
- "@phpsandbox/cli-linux-x64": "0.1.1",
27
- "@phpsandbox/cli-linux-arm64": "0.1.1",
28
- "@phpsandbox/cli-linux-x64-musl": "0.1.1",
29
- "@phpsandbox/cli-linux-arm64-musl": "0.1.1",
30
- "@phpsandbox/cli-windows-x64": "0.1.1"
24
+ "@phpsandbox/cli-darwin-arm64": "0.3.0",
25
+ "@phpsandbox/cli-darwin-x64": "0.3.0",
26
+ "@phpsandbox/cli-linux-x64": "0.3.0",
27
+ "@phpsandbox/cli-linux-arm64": "0.3.0",
28
+ "@phpsandbox/cli-linux-x64-musl": "0.3.0",
29
+ "@phpsandbox/cli-linux-arm64-musl": "0.3.0",
30
+ "@phpsandbox/cli-windows-x64": "0.3.0"
31
31
  }
32
32
  }