質問

Now that I am using namespaces in my php files which match the file's path, I have to append a namespace to pretty much every class instantiation. The namespaces definitely help my autoloader find files, but the code is becomming harder to read/write. aren't namespaces supposed to simplify my code? why is it making things more complicated? Am I using it wrong? Not sure I see how using a namespace is much better than having super long class names...

example:

file: /root_path/init.php

<?php
    namespace root_path;
    $foo = new \sub_path\bar();
?>

file: /root_path/sub_path/bar.php

<?php
    namespace root_path\sub_path;
    class bar {

    }
?>

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません softwareengineering.stackexchange
scroll top