Skip to main content

Getting started

Quick installation

We provide a Giter8 template, which you can apply to create a new project with Scala.php already set up.

sbt new scala-php/scala-php.g8

Installation (less quick)


Scala.php only supports Scala 3.3.0 and above.


Scala.php is still deep in development. Many features of the Scala language currently fail to compile.

Adjust your expectations accordingly.

In your project/plugins.sbt:

addSbtPlugin("org.scala-php" % "scala-php-sbt" % "0.1.1")

Now, you can enable the plugin on the modules you want to compile to PHP:

val main = project
.settings(scalaVersion := "3.4.0")


In order to start building with Scala.php, simply create a Scala file in the source root of your project and start writing Scala code:

object HelloWorld {

def main(args: Array[String]): Unit = {
val greeting = "hello"
println(s"$greeting world!")


Now, you can compile and run the code with the PHP interpreter.


You must have a PHP interpreter available. By default, the PATH is used. To specify a custom interpreter, see Configuration.

sbt run
hello world!

Check out the examples for more complex use cases.