erichard / SublimePHPCompanion

A Sublime Text plugin that provides cool stuff for PHP 5.3+ coding session.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

composer.json file path issue

msabev opened this issue · comments

Hi,

The new v2.0.0 is searching for the composer.json file in the root folder (which is currently opened). When the file is not there, but in a sub-folder (e.g. in project-name/application), the package is not working.

For instance when trying to import a namespace, the following error is thrown:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 1088, in run_
    return self.run(edit)
  File "/home/xxx/.config/sublime-text-3/Installed Packages/PHP Companion.sublime-package/php_companion/commands/import_namespace_command.py", line 22, in run
  File "/home/xxx/.config/sublime-text-3/Installed Packages/PHP Companion.sublime-package/php_companion/utils.py", line 85, in get_namespace
TypeError: 'NoneType' object is not subscriptable

Hi, i had trouble with psr-4 and composer.json too. In my case there is no composer.json, here is my pull request for default empty composer.json. https://github.com/erichard/SublimePHPCompanion/pull/135/files There in php_companion/utils.py line 76-79 is loaded composer file, you can add there iteration over sub-folders if file is not found.
And probably you will have trouble with prefixes (you nedd to add sub-folder path where the composer.json found as a prefix somewhere in get_namespace(filename).

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.