In many of my PHP micro-library, there are Class matching with project name, it create a strange fully qualified class name, look at this
<?php
namespace Javanile\MysqlImport;
class MysqlImport {
...
}
Then when I use this class, I have the annoying double name repetition
<?php
$importer = new \Javanile\MysqlImport\MysqlImport(...);
// OR (EVEN BAD)
use Javanile\MysqlImport\MysqlImport;
$importer = new MysqlImport(...);
According to PSR-4 we have:
Javanile
: is the vendor nameMysqlImport
: is the subpackage name it fixes the project nameMysqlImport
: is the principal class of the library
Please support me to handle the annoying double repetition of the project and principal class name on the full qualified class name. It is so bad, what's the right move? (I don't want to come up with random class names just to avoid it)
This is not wrong, but if you want more clean project, you can some reorganize your project structure. For example:
With this structure your
use
path will look asuse Javanile\Importers\Mysql;