Load my classes to my project

Hello!
I need your help. I want auto-includes my class to my project. But composer auto load don’t work. Please, help me.

Project:
src
—> composer.json
—>public–>
----------------->index.php
—>classees–>
------------------->User.php

Project/src/classes/User.php
Project/src/public/index.php
Project/src/composer.json

– src/publi/index.php - https://pastebin.com/17c41v0g
– src/composer.json - https://pastebin.com/KnLGUsU7

This isn’t a Slim issue, but try this:

"psr-4": {
    "Class\\": "src/classes/"
}

In your User.php at the top:

<?php
namespace Class;

class User {
    ...
}

Just some general tips:

  • The src/ directory is for the application specific PHP classes only.
  • Put your User.php class into the src/ sub-directory
  • The public/ directory should not be under the src/ directory
  • composer.json and vendor/ directory should be on top of the project root
  • Example: https://github.com/php-pds/skeleton

In your composer.json define the namespace paths like this:

"autoload": {
    "psr-4": {
        "App\\": "src"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Test\\": "tests"
    }
},

Hi! Class ‘Classes\Test’ not found

new composer.json -> https://pastebin.com/KnLGUsU7
new index.php -> https://pastebin.com/17c41v0g
new Test.php -> https://pastebin.com/RuX9X6rm
%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%20(113)