Herdy
Herdy

Reputation: 179

How to make Extending Class using PSR-4 autoload composer

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'm trying to extending 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 an error like this :

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 ?

Upvotes: 4

Views: 1226

Answers (1)

Fu Xu
Fu Xu

Reputation: 766

seems like it should be travelo_conf\ApiConfig rather than travelo_conf\config\ApiConfig

Upvotes: 2

Related Questions