Answers.Body: <p>Problem was with how composer handles psr-0 and psr-4 autoloading, so by changing the <code>composer.json</code> like such, the classes were loaded.</p>
  
  <pre><code>{
    "autoload":{
      "psr-4": {"PluginX\\": "PluginX/"}
    },
    "require": {
      "andrefelipe/orchestrate-php": "0.14.0"
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-30T02:49:41.620Z
Answers.LastActivityDate: 2015-06-30T02:49:41.620Z
Answers.UserDisplayName: Dale Inverarity
Body: <p>I have composer setup at the root of the plugin folder with a few dependencies. I have custom classes in a folder at root we can call pluginX, I am autoloading its namespace with composer like such.</p>
  
  <pre><code>{
    "autoload":{
      "psr-0": {"PluginX": "PluginX/"}
    },
    "require": {
      "andrefelipe/orchestrate-php": "0.14.0"
    }
  }
  </code></pre>
  
  <p>however when I try and use my class which resides at "PluginX/Models/Trips" like below I get a "Fatal Error: Class Not found..."</p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  use \GoWander\Models\Trips;
  use \andrefelipe\Orchestrate;
  use \GuzzleHttp\Client as GuzzleClient;
  
  class PluginX_TripController extends BaseController {
  
      protected $allowAnonymous = false;
  
      public function actionIndex() {
  
          // let's instantiate a Http client programatically
          $clientConfig = Orchestrate\default_http_config();
          $httpClient = new GuzzleClient($clientConfig);
  
          // instatiate the collection
          $trips = new Trips($httpClient);
  
          $trip = $trips-&gt;item('ING');
  </code></pre>
  
  <p>Any thoughts?</p>
  
Tags: <plugin-development>
Title: PSR-0 Composer Autoloading causing class not found in plugin
ThreadText: # PSR-0 Composer Autoloading causing class not found in plugin
  
  (Asked by: username_0 on 2015-06-29)
  
  I have composer setup at the root of the plugin folder with a few dependencies. I have custom classes in a folder at root we can call pluginX, I am autoloading its namespace with composer like such.
  
  ```
  {
    "autoload":{
      "psr-0": {"PluginX": "PluginX/"}
    },
    "require": {
      "andrefelipe/orchestrate-php": "0.14.0"
    }
  }
  
  ```
  
  however when I try and use my class which resides at "PluginX/Models/Trips" like below I get a "Fatal Error: Class Not found..."
  
  ```
  <?php
  namespace Craft;
  
  use \GoWander\Models\Trips;
  use \andrefelipe\Orchestrate;
  use \GuzzleHttp\Client as GuzzleClient;
  
  class PluginX_TripController extends BaseController {
  
      protected $allowAnonymous = false;
  
      public function actionIndex() {
  
          // let's instantiate a Http client programatically
          $clientConfig = Orchestrate\default_http_config();
          $httpClient = new GuzzleClient($clientConfig);
  
          // instatiate the collection
          $trips = new Trips($httpClient);
  
          $trip = $trips->item('ING');
  
  ```
  
  Any thoughts?
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-06-30. Score: 2 | Accepted answer
  
  Problem was with how composer handles psr-0 and psr-4 autoloading, so by changing the `composer.json` like such, the classes were loaded.
  
  ```
  {
    "autoload":{
      "psr-4": {"PluginX\\": "PluginX/"}
    },
    "require": {
      "andrefelipe/orchestrate-php": "0.14.0"
    }
  }
  
  ```
  
  
  ---
  
  