Gert-dev / php-ide-serenata

Atom IDE package that integrates the Serenata server to provide PHP code assistance
https://serenata.gitlab.io/
Other
274 stars 19 forks source link

Support creating new classlikes from the file browser #398

Open Gert-dev opened 6 years ago

Gert-dev commented 6 years ago

Creating PHP files by entering the namespace manually becomes cumbersome quickly. We can automatically fill out the namespace based on the folder hierarchy, although where it starts depends on the project (i.e. it could be configured in composer.json).

We do want to avoid tying ourselves to Composer unless absolutely necessary, IIRC PhpStorm has a way to mark a project folder as namespace root via the file browser.

twifty commented 6 years ago

I created a package templar to do something similar. Updating it is on my todo list, but it allows for creating classes/traits/interfaces from a user defined template and is able to populate the namesapce based on the directory structure. May be worth a look.

Gert-dev commented 6 years ago

I'm aware of it and have even used it a little bit. I realized later on that I usually just end up copying existing classes and updating their namespace and name to get around.

Since templar seems to support custom scripts, you could in theory go as far as to use the folder structure to determine the namespace name automatically (I've thought of doing that, too!).

It would be even nicer if there was some sort of automatic intelligence behind it that could use advanced information - seeing as things like extracting interfaces and all that would need to be done at some point anyway -, hence this ticket.