Get the App Namespace in Laravel 5 -


i developing package laravel 5, if user change default namespace of application package command php artisan app:name test won't work properly. package needs know app's namespace work properly.

based on understanding laravel 5 doesn't provide namespace of app in of core classes

so decided either namespace composer.json file

   "psr-4": {         "appnamespace\\": "app/"     } 

or ask user provide namespace of application in kind of config file.

question: please let me know if presumption laravel doesn't provide correct , if correct please let me know way best way namespace or if have better suggestion?

you can app's namespace using below trait included core of laravel:

illuminate\console\appnamespacedetectortrait 

laravel uses trait in appnamecommand current namespace before updated.

an example:

class myclass {      use \illuminate\console\appnamespacedetectortrait;      public function getnamespace()     {         return $this->getappnamespace();     }  } 

you can read more traits here.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -