How to create an advanced class using startup PSR-4

I have a directory structure like this:

Directory

and this is my composer .json:

 {
    "autoload": {
        "psr-4": {
            "travelo_conf\\": "config/",
            "travelo_url\\": "url/"
        }
    }
}

now i am trying to extend my api class with hotel class

this is my ApiConfig class:

namespace travelo_conf\config ;

    class ApiConfig {}

and this is my hotel class:

<?php 

namespace travelo_url\hotelbedsUrl ;

require '../vendor/autoload.php';

use travelo_conf\config\ApiConfig ;


     class Hotels extends ApiConfig 
        {

            function __construct()
            {
                parent::__construct() ;

            }
    }

and I got the error:

Fatal error: Class 'travelo_conf \ config \ ApiConfig' not found in / var / www / html / 4travelo_Beta / url / getHotelUrl.php on line 9

can someone explain to me why?

+4
source share
1 answer

It looks like it should be travelo_conf\ApiConfig, nottravelo_conf\config\ApiConfig

+2
source

Source: https://habr.com/ru/post/1661393/


All Articles