Let’s say i’ve declared a namespace like this:
<?php
// File kitchen.php
namespace Kitchen;
?>
Why do i still have to include that file in all other files where i want to use kitchen.php
Doesn’t PHP know that kitchen.php resides in Kitchen namespace?
Thanks for answers.
Namespaces make it extremely easy to create autoloaders for any class within your project as you can directly include the path to the class within the call.
An pseudo code namespace example.
Then within your ./rooms/ folder you have 3 files:
bedroom.phpbathroom.phpkitchen.phpThen report classes what classes are loaded
Hope it helps