eminmuhammadi / phpcompiler
The basic PHP Compiler for Python , Cpp , Java , C11 , C
Fund package maintenance!
www.paypal.me/eminmuhammadi
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 3
Open Issues: 1
Language:JavaScript
Type:project
Requires
- php: >=7.3.1
This package is auto-updated.
Last update: 2024-09-27 01:18:48 UTC
README
The basic PHP Compiler for Python , Cpp , Java , C11 ,C
git clone https://github.com/eminmuhammadi/phpCompiler.git
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Prerequisites
What things you need to install the software and how to install them
apt-get install g++
apt-get install gcc
apt-get install clang
apt-get install javac
apt-get install python
Installing
Main source code is located in src/phpCompiler.php
. For using this class in project you need to set up:
require_once 'vendor/autoload.php';
and Create new class using eminmuhammadi\phpCompiler()
$COMPILER = new eminmuhammadi\phpCompiler();
Testing
After installing recomended to run Test service in test/testAll.php
Declare variables
$env = [ 'command' => 'g++ -std=c++11', 'executable' => 'a.out', 'runFile' => './a.out' , //out 'time' => '1', //seconds 'code' => $_POST['code'] , 'input' => $_POST['input'], 'fnCode' => 'main.cpp', 'fnInput' => 'input.txt', 'fnError' => 'error.txt' ];
time
makes executation against to looping
Set time for executation (Attention)
$COMPILER->setTimeOut($time);
This rule make php file against to looping.
Run & Create JSON Service
Collect all datas for compile procession.
$RESULT = $COMPILER->Run( $env['command'], $env['time'], $env['executable'], $env['runFile'], $env['code'], $env['input'], $env['fnCode'], $env['fnInput'], $env['fnError'] );
That's all and we need to create application service a json type.
header('Content-Type: application/json'); $data = [ 'code' => $env['code'] , 'time_limit' => $time, 'input' => $env['input'], 'result' => $RESULT ]; echo json_encode($data,JSON_PRETTY_PRINT);
JSON shows like :
{ "code": " #include <iostream>\r\n #include <string>\r\n using namespace std;\r\n\r\n int main()\r\n {\r\n\r\n cout <<\"Hello World\"<<endl;\r\n return 0;\r\n }\r\n ", "time_limit": 1000, "input": "", "result": { "output": "Hello World\n", "time": "0.01", "error": "", "verdict": "AC" } }
Verdicts
Authors
- Emin Muhammadi - Initial work - eminmuhammadi
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details