Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer PSR-4 Autoload Interface Deprecation Notice

I'm having trouble understanding what's wrong with this simple interface.

<?php

namespace App\Interfaces;

use Illuminate\View\View;

interface renderData
{
        public function renderAsHtml(): View;
}

When I composer dump-autoload i receive the following notice

Deprecation Notice: Class App\Interfaces\renderData located in ./app/Interfaces/RenderData.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0.

composer.json autoload part:

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

Folder structure is:

<root_project>
 app
 Console
 ...

I have already try to rename app to App then dump-autoload but the problem persist.

like image 845
Alberto Ar3s Avatar asked Jun 10 '20 21:06

Alberto Ar3s


2 Answers

It could be that first letter of ‘app’ folder is in small case in app/Interfaces/RenderData’, but in the namespace is in upper case in ‘App\Interfaces’.

Make sure the folder structure and naming matches namespace.

like image 189
Svetlozar Stoyanov Avatar answered Oct 05 '22 19:10

Svetlozar Stoyanov


This is the main reason for composer's latest version.

Check your composer version using

composer -V

Install another version using

composer self-update 1.6.3

and delete the vendor folder from your project.

And use the following commands:

composer install
composer update
composer dump-autoload

Hope it will work.

like image 20
Mahadi Hassan Babu Avatar answered Oct 05 '22 19:10

Mahadi Hassan Babu