title: Generating a PHAR for a simple application
body: <p>I'm experimenting in building CLI tools using the Symfony2 console library. I've got something basic working and now I want to package it as a phar. I've read a few examples but the ones I've seen are very simple (3 files, no namespaces, etc).</p>
  
  <p>In my <code>src/</code> directory I have the following:</p>
  
  <p><img src="https://i.stack.imgur.com/TpHAV.png" alt="enter image description here"></p>
  
  <p>Above <code>src/</code> I have a <code>console.php</code> that I execute to run the app. I also have a <code>vendors/</code> dir as I'm using composer to install dependencies. <code>console.php</code> is very simple:</p>
  
  <pre class="lang-php prettyprint-override"><code>#!/usr/bin/env php
  &lt;?php
  
  set_time_limit(0);
  $loader = require 'vendor/autoload.php';
  
  use Symfony\Component\Console\Application;
  use Bendihossan\Pinfo\Command\EnvironmentCommand;
  use Bendihossan\Pinfo\Command\ExtensionsCommand;
  use Bendihossan\Pinfo\Command\RunAllCommand;
  
  $console = new Application();
  
  $console-&gt;add(new RunAllCommand());
  $console-&gt;add(new EnvironmentCommand);
  $console-&gt;add(new ExtensionsCommand);
  
  $console-&gt;run();
  </code></pre>
  
  <p>From what (little) I understand about build a phar I think I need to include <code>console.php</code> as the stub and everything else in <code>src/</code> plus all my dependencies in <code>vendors/</code>. </p>
  
  <p>Looking at the example code on <a href="http://phpmaster.com/packaging-your-apps-with-phar/" rel="noreferrer">phpmaster.com</a> they specify every file manually to be included in the phar using <code>file_get_contents</code>, but I need to maintain my directory structure in order to use the composer's autoloader and keep to PSR-0 directory structure.</p>
  
  <p><strong>Is there an easy way to create a .phar and maintain my directory structure within it so I can still use composer's autoloader?</strong></p>