8

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.

yivi
  • 42,438
  • 18
  • 116
  • 138
Alberto Ar3s
  • 311
  • 1
  • 3
  • 14
  • 2
    can edit the post and you share `autoload` part of your `composer.json` ? Also what is the folder structure of this class ? – Ersoy Jun 10 '20 at 22:14
  • 1
    Done, i think it's the 'App' 'app' problem... – Alberto Ar3s Jun 11 '20 at 13:04
  • 1
    Check for case-sensitive file and class names - you've named your file `RenderData.php` with a capital `R`, but your interface uses a lower-cased `r` – Nico Haase Jul 15 '20 at 09:33
  • Thanks @NicoHaase Typo on my side. I was wondering why all the others were working and this specific interface was throwing a warning. Since I always follow a standard, I had not paid attention to the namings – Kalema Edgar Oct 11 '21 at 15:40

2 Answers2

11

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.

5

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.

PiCTo
  • 924
  • 1
  • 11
  • 23