mardi 4 août 2015

Composer, class within my package is not being autoloaded in application using it

I'm creating a module which I will include in several projects. However, in a project that uses the module, the autoloader doesn't seem to include the class in the module.

The module structure (etc) is as follows:

Directory structure in the git repository:

/
/composer.json
/src/
/src/EbayAPI.php

composer.json:

{
    "name": "jodes/ebay-api",
    "autoload": {
        "psr-4" : {
            "Jodes\\EbayAPI\\" : "src"
        }
    }
}

EbayAPI.php:

<?php
namespace Jodes;
class EbayAPI {}

And the application I'm trying to include it in has the following:

composer.json:

{
    "require": {
        "behat/behat": "@stable",
        ....other requirements in here...
        "jodes/ebay-api": "dev-master"
        },
    "config": {
        "bin-dir": "bin/"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "http://ift.tt/1P3M0gX"
        }
    ]
}    

And the php file that wants to use my package via the autoloader is:

<?php

use Jodes\EbayAPI;
require_once 'vendor/autoload.php';

class HelloWorld {
    public function __construct(){
        $ebay = new EbayAPI();
    }
}

The error I get is

Fatal error: Class 'Jodes\EbayAPI' not found

What am I doing wrong? Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire