After recieving the request the following code compiles it
if ($request->lang === 'C') {
    $outputGcc = shell_exec('gcc '.escapeshellarg(storage_path('app/codes/'.$codefile))
            .' -o '.escapeshellarg(storage_path('app/codes/progs/'.$exefile)).' 2>&1');
} else if ($request->lang === 'C++') {
    $outputGcc = shell_exec('g++ '.escapeshellarg(storage_path('app/codes/'.$codefile))
            .' -o '.escapeshellarg(storage_path('app/codes/progs/'.$exefile)).' 2>&1');
}
We open a process with proc_open() and handle it through the following code
if ($request->lang === 'C' || $request->lang === 'C++') {
    $process = proc_open('./'.$exefile, $descriptorspec, $pipes, storage_path('app/codes/progs'));
} else if ($request->lang === 'Java') {
    $process = proc_open('java '.$exefile, $descriptorspec, $pipes, storage_path('app/codes/progs'));
}
Read the docs at http://php.net/manual/en/function.proc-open.php to understand the rest of the code.