V
V
vrazbros2021-06-14 15:54:09
PHP
vrazbros, 2021-06-14 15:54:09

Do these settings match the PSR-4?

for my mini project I use the following settings for auto-launching in composer

"autoload": {
    "psr-4": {"App\\": "src/App"}
},


in the project, for example, there is a player class, it lies in the Player folder, then the full path to the player class:
src/App/Player/Player.class.php
its namespace: and for example to the Game class: its namespace: index.php is located in the root of the project, those are on the same level with src, does such a project structure correspond to PSR- 4 ?
namespace App\Player;

src/App/Game/Game.class.php
namespace App\Game;


Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gian_tiaga, 2021-06-14
@gian_tiaga

Almost, you just need to remove the word class from the class name. The file must be named the same as the class, but with the .php extension. And the class name itself must be capitalized

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question