Skip to content
Advertisement

How to use python in laravel project for search in mysql database [closed]

I want to know how can i use python to search and into mysql of my PHP Laravel project and send back the results into php file

Advertisement

Answer

Its not complicated, See link blow : https://laracasts.com/discuss/channels/laravel/running-python-in-laravel

The Laravel Script :

// $json = an encoded JSON string
$process = new Process("python3 /Path/To/analyse_json.py {$json}");
$process->run();

// executes after the command finishes
if (!$process->isSuccessful()) {
    throw new ProcessFailedException($process);
}


dump(json_decode($process->getOutput(), true));
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement