If this is the directory structure
This is test.class.php the inside of the code
php
这是 IndexController.class.php 下的代码
php
我想达到的效果是在 test.class.php 下不把命名空间命名成 namespace Common\Common; 而是命名为 namespace Common; 也能在 IndexController.class.php 实例化 test.class.php 这样就可以减少一个目录,因为我在另一个业务里有一个目录名是变量 想跳过那个目录 能实现的实例吗 真心求解答
Reply content:
If this is the directory structure
This is test.class.php the inside of the code
php
这是 IndexController.class.php 下的代码
php
我想达到的效果是在 test.class.php 下不把命名空间命名成 namespace Common\Common; 而是命名为 namespace Common; 也能在 IndexController.class.php 实例化 test.class.php 这样就可以减少一个目录,因为我在另一个业务里有一个目录名是变量 想跳过那个目录 能实现的实例吗 真心求解答
can.
Recommended article: PHP namespace FAQ
If you use automatic loading, you can't change the rules of automatic loading, you can use import or vendor to introduce class libraries, there is no need to tangle. If you really want to do this, then Class Library mapping can help you. View Document: Http://document.thinkphp.cn/manual_3_2.html#autoload