See the code here: gist.github.com/3102439
The problem I’m having is that I cannot perform a double-substitution pulling the namespace from the file path AND converting “/” to “”.
See the code here: gist.github.com/3102439
The problem I’m having is that I cannot perform a double-substitution pulling the namespace from the file path AND converting “/” to “”.
Even though this is 6 years late, still people mind find this through google, as I landed here without finding a proper solution before. I already posted a comment to your gist.
In short, I was looking for a Sublime Text snippet that creates a class for Laravel projects, where the classes are all below the app folder. Its namespace should start with a capital letter though:
namespace App${TM_FILEPATH/(?:.*app)|(\/)([^\/]+)(?=\/)|(?:\/[^\/]+\.php$)/(?1:\\$^N:$^N)/g};
class ${TM_FILENAME/\.php$//}
You can just replace the App (and app) with MyApp for your directory structure. This regex is based on the solution from Sublime Text snippet to insert PSR-0 namespace with minor adjustments.
HTH