Putting sudo scripts embedded in php code at user clicks is not advisable nor desirable.
It is a major security issue and should be treated like that.
Why not use existing tools, which have agents and API(s) at your disposal.
Include those in your project if you require such actions.
Restarts, deployments will be transparent to user, not dependent on application itself and fairly secure.
If you really need user interaction for such tasks, otherwise cron is fine, and best would be to see why application needs to be restarted
Hope that helps
Regards
Peasant.