When working with small projects, we can use the autload function:
use classes\BookProduct; use classes\NotebookProduct; require_once 'classes/Product.php'; require_once 'classes/Gadget.php'; require_once 'classes/NotebookProduct.php'; require_once 'classes/BookProduct.php'; function autoloder1($class) { $class = str_replace("\\", '/', $class); $file = __DIR__ . "/{$class}.php"; if(file_exists($file)){ require_once $file; } } spl_autoload_register('autoloder1');