My wild guess: are you doing include 'orders.php';
from inside of orders.php
? If so, don't: you only need to include a file if it's separate from the one you're currently in. In the second example, that would lead to an infinite loop of including the file, which executes that code, which includes itself, which executes the code, which...eventually runs out of memory. In the first example, it could be similar, in that during the initial execution, you create those (namespaced) classes, but then try to create them again on the self-include.
Generally for "normal" use where you have a class defined in one file and want to use it in a second file, in that second file you do include_once
(or probably better: require_once
), so that it only includes that file if it has not yet done so.