Skip to content

Command line ​

sphp <COMMAND>

  init    Create a new StirPHP project in the current directory
  check   Type-check the project
  build   Transpile the project to plain PHP
  lsp     Run the language server (over stdin/stdout)

sphp looks for sphp.toml in the current directory and its parents; that directory is the project root.

sphp init ​

sphp init [OPTIONS]
Option
-y, --yesAccept the defaults (and any flags given) without prompting
-f, --forceOverwrite an existing sphp.toml
--name <NAME>Project name (defaults to the directory name)
--src-dir <DIR>Source directory (default src)
--out-dir <DIR>Output directory (default build)

Creates sphp.toml and src/main.sphp, and adds the output directory to .gitignore. An existing composer.json or phpstan.neon is detected and reported.

sphp check ​

sphp check [OPTIONS] [PATHS]...
Option
[PATHS]...Only report diagnostics for files under these paths
--format <human|json>Output format (default human)
--no-vendorDon't load vendor files from Composer autoload rules
--max-errors <N>Show at most N diagnostics (all are still counted)

Exits with status 1 when there are errors. With --format json, each diagnostic has file, line, column, endLine, endColumn, severity, code, message, labels and notes.

sphp build ​

sphp build [OPTIONS]
Option
--out-dir <DIR>Output directory (overrides outDir)
--inline-extensionsInline extension function calls (also inlineExtensions in sphp.toml)
--no-source-mapsDon't write .php.map source maps
-w, --watchRebuild whenever sources or sphp.toml change
-f, --forceWrite output even if type-checking reports errors

The output mirrors the source tree. Files that a previous build wrote but no longer correspond to a source are removed.

With --force, a file with syntax errors still isn't written, and the exit status is still 1.

sphp lsp ​

Runs the language server over stdin and stdout. Editors start it themselves. Set SPHP_LOG=debug to log to stderr.

StirPHP is open source under the MIT license.