src/Package.php
public function getPackageRoot()
    {
        $type = $this->getPackageType();
        if ($type === self::TYPE_PSEUDO) {
            return false;
        }

        if (is_string($this->packageRoot)) {
            return $this->packageRoot;
        }

        //determine where it is located
        //luckily we know where we are in vendor folder :)
        //is there a better recommended way?
        $root = __DIR__ . '/../../..';

        //HAX using the composer package to get the root of the vendor folder
        //is there a better recommended way?
        if (class_exists(SpdxLicenses::class)
            && method_exists(SpdxLicenses::class, 'getResourcesDir')
            && realpath(SpdxLicenses::getResourcesDir() . '/../../..')
        ) {
            $root = realpath(SpdxLicenses::getResourcesDir() . '/../../..');
        }

        //if it's a root package
        if ($type === self::TYPE_ROOT) {
            $root .= '/..';
        }

        $this->packageRoot = realpath($root);

        return $this->packageRoot;
    }
public function getPackageRoot()
    {
        $type = $this->getPackageType();
        if ($type === self::TYPE_PSEUDO) {
            return false;
        }

        if (is_string($this->packageRoot)) {
            return $this->packageRoot;
        }

        //determine where it is located
        //luckily we know where we are in vendor folder :)
        //is there a better recommended way?
        $root = __DIR__ . '/../../..';

        //HAX using the composer package to get the root of the vendor folder
        //is there a better recommended way?
        if (class_exists(SpdxLicenses::class)
            && method_exists(SpdxLicenses::class, 'getResourcesDir')
            && realpath(SpdxLicenses::getResourcesDir() . '/../../..')
        ) {
            $root = realpath(SpdxLicenses::getResourcesDir() . '/../../..');
        }

        //if it's a root package
        if ($type === self::TYPE_ROOT) {
            $root .= '/..';
        }

        $this->packageRoot = realpath($root);

        return $this->packageRoot;
    }
public function getPackageRoot ( ) { $ type = $ this -> getPackageType ( ) ; if ( $ type === self :: TYPE_PSEUDO ) { return false ; } if ( is_string ( $ this -> packageRoot ) ) { return $ this -> packageRoot ; } //determine where it is located //luckily we know where we are in vendor folder :) //is there a better recommended way? $ root = __DIR__ . '/../../..' ; //HAX using the composer package to get the root of the vendor folder //is there a better recommended way? if ( class_exists ( SpdxLicenses :: class ) && method_exists ( SpdxLicenses :: class , 'getResourcesDir' ) && realpath ( SpdxLicenses :: getResourcesDir ( ) . '/../../..' ) ) { $ root = realpath ( SpdxLicenses :: getResourcesDir ( ) . '/../../..' ) ; } //if it's a root package if ( $ type === self :: TYPE_ROOT ) { $ root .= '/..' ; } $ this -> packageRoot = realpath ( $ root ) ; return $ this -> packageRoot ; }
Returns the root path of the project

@return string|false
Returns the root path of the project