PHP code example of aa-ahmed-aa / dorm

1. Go to this page and download the library: Download aa-ahmed-aa/dorm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aa-ahmed-aa / dorm example snippets



use Ahmedkhd\Dorm\Dorm;

$obj = new Executor('cpp');

//set compilation path
$obj->setCompilationPath( __DIR__ );
echo $obj->getCompilationPath();

$cpp_code = <<<'EOT'
	#
	int main()
	{
	    cout<<"hello, c plus plus";
	    return 0;
				}
EOT;
	
$comp = $obj->compile($cpp_code);
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;

$obj = new Executor('java');
$comp = $obj->compile($java_code);
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;

$obj = new Executor('python2');
$comp = $obj->compile( $python_code);
echo "Running : " . implode( $comp )  . "\n";

	$compilers = [
		"__COMPILER_NAME__"=>[
			"path" => "__COMPILER_PATH__",
			"file_extension" =>'__CODE_FILE_EXTENSION_',
			"compile_func" => __NAME_FOR_YOUR_COMPILER_FUNCTION__,
			"run_func" => __NAME_FOR_YOUR_RUN_FUNCTION__
		]
	];