Franky238
Franky238

Reputation: 519

Composer for autoloading php

Hi i have this folder structure:

Folder structure

I'm using composer for autoloading my files but it is dont work .. i do it first time and i dont know how to implement this.

My composer.json

{
"name": "Some name",
"description": "Some Framework",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
    {
        "name": "Some names of authors",
        "email": "[email protected]"
    }
],
"autoload": {
    "psr-4": {
        "Apison": "/../sdk/"
    }
}

}

And my index.php

    <?php
require_once 'vendor/autoload.php';

$app = new \Apison\Sdk\App();

When i update my composer it will write: Nothing to load and PHP will catch exeption on line with $app = new \Apison\Sdk\App();

Thanks for your tips

Upvotes: 1

Views: 1859

Answers (1)

m79lkm
m79lkm

Reputation: 3070

namespaces need \\:

"Apison\\": "../sdk"

documentation:

https://getcomposer.org/doc/04-schema.md#psr-4


Based on our chat, the solution is this:

"autoload": {
    "psr-4": {
        "Apison\\Sdk\\": "sdk"
    }
}

Then the namespaces and file structure was changed to comply with the psr-4 standard

Upvotes: 1

Related Questions