public function getNamespace()
    {
        if(!is_null($this->appNamespace)) {
            return $this->appNamespace;
        }

        $composer = json_decode(file_get_contents(base_path().'/composer.json'));

        foreach($composer->autoload->{"psr-4"} as $namespace => $path) {
            if(realpath(app_path()) === realpath(base_path(). '/' .$path))  {
                return $this->appNamespace = $namespace;
            }
        }

        throw new Exception("Namespace detect problem.");
    }
public function getNamespace()
    {
        if(!is_null($this->appNamespace)) {
            return $this->appNamespace;
        }

        $composer = json_decode(file_get_contents(base_path().'/composer.json'));

        foreach($composer->autoload->{"psr-4"} as $namespace => $path) {
            if(realpath(app_path()) === realpath(base_path(). '/' .$path))  {
                return $this->appNamespace = $namespace;
            }
        }

        throw new Exception("Namespace detect problem.");
    }
public function getNamespace ( ) { if ( ! is_null ( $ this -> appNamespace ) ) { return $ this -> appNamespace ; } $ composer = json_decode ( file_get_contents ( base_path ( ) . '/composer.json' ) ) ; foreach ( $ composer -> autoload -> { "psr-4" } as $ namespace => $ path ) { if ( realpath ( app_path ( ) ) === realpath ( base_path ( ) . '/' . $ path ) ) { return $ this -> appNamespace = $ namespace ; } } throw new Exception ( "Namespace detect problem." ) ; }
To get application namespace

@return string
@throws Exception
To get application namespace