2

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?

2

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"
  }
}
1
  • Thank you! Had the same issue-- was trying to use psr-0, but when I switched to the psr-4 syntax it worked...
    – user5265
    Jun 10 '16 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.