First you need to setCompilationPath in this path the package will create files of the code and compile and run your code so let's compile and run your first cpp code
require ('vendor/autoload.php');
use Ahmedkhd\Dorm\Dorm;
$obj = new Executor();
//set compilation path
$obj->setCompilationPath( __DIR__ );
echo $obj->getCompilationPath();
$cpp_code = <<<'EOT'
#include< iostream >
using namespace std;
int main()
{
cout<<"hello, c plus plus";
return 0;
}
EOT;
$comp = $obj->compile( $cpp_code, "cpp" );
echo "Compilation : " . ( ! is_array($comp) ? "Success" : "Fail" ) . "\n";
echo "Running is : " . ( ! is_array($comp) ? $obj->run() : "Fail" ) . "\n";
//java
$java_code = <<<'EOT'
public class Main {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, Java");
}
}
EOT;
$comp = $obj->compile( $java_code, "java" );
echo "Compilation : " . ( ! is_array($comp) ? "Success" : "Fail" ) . "\n";
echo "Running is : " . ( ! is_array($comp) ? $obj->run() : "Fail" ) . "\n";
$python_code = <<<'EOT'
print "Hello, Python3.4"
EOT;
$comp = $obj->compile( $python_code, "python2" );
echo "Running : " . implode( $comp ) . "\n";