0

I am using both namespace and require and i'm a bit confused: require means I basically load that file into memory, and namespaces basically gives me an auxiliary way to navigate and 'categorize' my classes, yet I have no idea if I'm doing it right as it looks messy.

I did resolve to tutorials yet they explain the basic gist of it and never go into design and best practice.

my structure:

root

root>models>User.php

root>services>API.php

root>services>Database.php

root>services>Logger.php

User.php

namespace Models;
use Services\API;
require dirname(__FILE__).'/../services/API.php' ;

class User{}

API.php

namespace Services;
class API{}

Dealing with Laravel for more than a while I've never seen any class that has a require/include in them, i'm sure they are using some hoisting mechanism to call those files, yet everything there looks nice and tucked in.

Please suggest / teach me how to use namespaces where ATM my immediate task is to call API from my models directory classes / Model namespace.

ASSILI Taher
  • 1,210
  • 2
  • 9
  • 11
clusterBuddy
  • 1,523
  • 12
  • 39

0 Answers0