Kavian Rabbani Kavian Rabbani - 4 months ago 13
PHP Question

file doesnt exists in routes Http directory laravel 5

I have a python script beside 'routes.php' and I want to execute that from 'routes.php' file .
when i use exec() function it does not work correctly .
so , i try

file_exists()
:

Route::get('/py', function(){
if (file_exists( "new.py" ))
echo "succeed";
else
echo "failed";
});


it only returns failed , so how can I get output from .py file via exec function ?

Answer

You need to use the absolute path, try with

 file_exists(__DIR__.'/new.py')

Assuming that it is in the same directory as routes.php