Symfony: Forget About Permission Settings

Ever wanted to forget about going into looking for the configuration chapter of the book and copy pasting the long commands to set acl’s right on your systems? That is not only on your local but also on your server?

Well there was a discussion in a DX ticket that today I stumbled upon and here it is and skimming over it I found this pearl from @umpirski. It is called umpirsky/composer-permissions-handler and here it is how you set it up:

         "symfony/monolog-bundle": "~2.4",
         "sensio/distribution-bundle": "3.0.*@dev",
         "sensio/framework-extra-bundle": "~3.0",
-        "incenteev/composer-parameter-handler": "~2.0"
+        "incenteev/composer-parameter-handler": "~2.0",
+        "umpirsky/composer-permissions-handler": "dev-master"
     "require-dev": {
         "sensio/generator-bundle": "~2.3"
 @@ -32,7 +33,8 @@
-            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
+            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
+            "Umpirsky\\PermissionsHandler\\ScriptHandler::setPermissions"
         "post-update-cmd": [
 @@ -49,6 +51,7 @@
     "extra": {
         "symfony-app-dir": "app",
         "symfony-web-dir": "web",
+        "writable-dirs": ["app/cache", "app/logs"],
         "incenteev-parameters": {
             "file": "app/config/parameters.yml"

In mac it works like a charm and I am sure it works the same way in servers due to its nice phpspec’ed logic:

namespace Umpirsky\PermissionsHandler;
use Umpirsky\PermissionsHandler\Exception\PathNotFoundException;
class SetfaclPermissionsSetter extends PermissionsSetter
    public function setPermissions($path)
        if (!is_dir($path)) {
            throw new PathNotFoundException($path);
        $this->runCommand('setfacl -R -m u:"%httpduser%":rwX -m u:`whoami`:rwX %path%', $path);
        $this->runCommand('setfacl -dR -m u:"%httpduser%":rwX -m u:`whoami`:rwX %path%', $path);

It is a very good example to learn and review phpspec niceties too!

Enjoy, thanks @umpirski for a nice package!

3 thoughts on “Symfony: Forget About Permission Settings

    • +1 to run php-fpm pool with own user/group and host projects inside home dir. This solution works perfectly for both Linux and Mac for many years for me.

    • no scusa miguel, bersani non è l&r8#17;e2ede degli eredi del movimento operaio ma uno stimabile signore del partito democratico che ha ben poco a che fare con questo glorioso movimento del Novecento.Il movimento operaio non ha eredi.

Leave a Reply to Loïc Chardonnet Cancel reply

Your email address will not be published. Required fields are marked *