sublime-php-namespace icon indicating copy to clipboard operation
sublime-php-namespace copied to clipboard

PSR-4 Autoloading

Open jeremyworboys opened this issue 11 years ago • 2 comments

Any chance of getting support for PSR-4?

I imagine this will add a level of complexity as you will now need to interpret composer.json for the root namespace.

jeremyworboys avatar Feb 04 '14 09:02 jeremyworboys

I don't see where the plugin requires special support for the PSR-4?

If I understand correctly, only the file structure changes between PSR-0 and PSR-4, the "namespace" written in the PHP file is the same right?

The plugin searchs and uses the "namespace" that is before the keyword "class", "interface", "trait", etc.. in the file to build the "use". it should not be a change with PSR-4.

If there is a subtlety that I don't understand, thank you explain it to me.

Heer0 avatar Feb 07 '14 09:02 Heer0

The issue I am having is with the php_namespace_insert_namespace command.

My composer.json looks like this:

{
  [...]
  "autoload": {
    "psr-4": {
      "Jeremyworboys\\Package\\": "src"
    }
  },
  [...]
}

If I then run the php_namespace_insert_namespace within src/File.php, nothing is inserted (instead of the expected namespace Jeremyworboys\Package;).

If I run the command from src/Exceptions/SomeException.php it inserts namespace Exceptions; instead of namespace Jeremyworboys\Package\Exceptions;

Basically, it isn't prefixing the vendor and package namespace from composer.json when inserting the namespace into the file.

jeremyworboys avatar Feb 08 '14 00:02 jeremyworboys