lundi 24 juillet 2017

Laravel 5.4 application can't load custom class in custom directory

I've followed this answer and some other but couldn't get this work.

I have custom directory in App -> libraries which holds custom php class. In composer.json I've added it in psr-4 section

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/",
        "libraries\\": "app/libraries"

    }
},

In the controller in which I want to use the class App\Http\Controller\OrderController.php I've added this

use App\libraries\API; // on top of the page


class OrderController extends BaseController
{
    public function orderSubmit()
    {
           // some code 
        API::convertUSDToEUR($product['price']);
    }
}

The error

FatalThrowableError Class 'App\libraries\API' not found

I've do composer dump-autoload too



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire