In Laravel sometime I uptade environment values with sed with:
sed -i '/^MAIL_DRIVER=/s/=.*/=log/' .env
Can anyone propose and alternative to do this with PHP?
UPDATE: I used Laravel/dotenv .env file as a example to give some context to the question but I'm not interested in how to change enviroment variables programatically my interest is how to perform sed "like" operations with php file manipulation function or if exists some library to do that. I also know i could use system o passthru functions, that's what I'm already doing I just curios about how to manipulate files in this way using PHP