How can I touch a file as sudo when using [Symfony's Filesystem][1]?
So far I have:
$fs = new Filesystem();
$confFile = sprintf('/etc/apache2/sites-available/%s.conf', $input->getArgument('name'));
$fs->touch($confFile);
But this code fails with error: Permission denied
.
[1]: http://symfony.com/doc/current/components/filesystem/introduction.html
From the Symfony Filesystem component:
As you see there, the
touch()
method is just a simple wrapper around PHP's buildintouch()
function. If you need to run touch with elevated rights via sudo, you have to call it directly: