title: Avoiding using sudo with Composer
body: <p>I am trying to set up a bare-bones implementation of GraphAware's Neo4j PHP Client, following the <a href="https://github.com/graphaware/neo4j-php-client/blob/master/README.md#installation-and-basic-usage" rel="nofollow">ReadMe</a>. I am working on PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )</p>
  
  <p>To get this to work, I find that I must use <code>sudo</code> with Composer, against the warnings given by Composer itself.</p>
  
  <hr>
  
  <p>I have installed Composer, as follows (<a href="https://getcomposer.org/download/" rel="nofollow">instructions</a>)</p>
  
  <pre><code>php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
  sudo php composer-setup.php
  </code></pre>
  
  <p>This led to the following announcement of success:</p>
  
  <pre><code>Composer successfully installed to: /home/blackslate/composer.phar
  </code></pre>
  
  <p>I then moved Composer so that it is available globally, as described <a href="https://getcomposer.org/doc/00-intro.md#globally" rel="nofollow">here</a>:</p>
  
  <pre><code>sudo mv /home/blackslate/composer.phar /usr/local/bin/composer
  </code></pre>
  
  <hr>
  
  <p>Next, I installed the latest neo4j-php-client:</p>
  
  <pre><code>sudo apt-get install php-bcmath
  sudo composer require graphaware/neo4j-bolt
  composer require graphaware/neo4j-php-client:^4.0
  </code></pre>
  
  <p>The <strong>Installation and basic usage</strong> instructions do not include the first two steps above, but the final command fails without them.</p>
  
  <p>The second line showed a warning not to run Composer as root, but if I did not, then I got the following error:</p>
  
  <pre><code>Installation failed, reverting ./composer.json to its original content.
  
  
  [ErrorException]                                                             
  file_put_contents(/home/blackslate/vendor/composer/installed.json): failed   
  to open stream: Permission denied   
  </code></pre>
  
  <p>This installed a directory named vendor in my home directory. I moved it to my project directory.</p>
  
  <hr>
  
  <p>Finally, in my project folder, I created a file named index.php with the following script:</p>
  
  <pre><code>&lt;?php
  
  require_once 'vendor/autoload.php';
  
  use GraphAware\Neo4j\Client\ClientBuilder;
  
  $client = ClientBuilder::create()
      -&gt;addConnection('default', 'http://neo4j:password@localhost:7474') // Example for HTTP connection configuration (port is optional)
      -&gt;addConnection('bolt', 'bolt://neo4j:password@localhost:7687') // Example for BOLT connection configuration (port is optional)
      -&gt;build();
  </code></pre>
  
  <p>I now have a directory with the following structure:</p>
  
  <pre><code>index.php            // as shown above
  vendor/              // the directory installed by Composer
         autoload.php
         composer/
         graphaware/
         guzzlehttp/
         myclabs/
         psr/
         symfony/
  </code></pre>
  
  <p>All appears to work as expected.</p>
  
  <p>My question is: is there a way I could have achieved this without using <code>sudo</code> to run Composer?</p>