Get Installed packages & their Dependencies

@param $packagesArray
@return array
337970
public static function getPackagesAndDependencies($packagesArray)
    {
        foreach ($packagesArray as $key => $value) {
            $packageFile = base_path("/vendor/{$key}/composer.json");

            if ($key !== 'php' && file_exists($packageFile)) {
                $json2 = file_get_contents($packageFile);
                $dependenciesArray = json_decode($json2, true);
                $dependencies = array_key_exists('require', $dependenciesArray) ? $dependenciesArray['require'] : 'No dependencies';
                $devDependencies = array_key_exists('require-dev', $dependenciesArray) ? $dependenciesArray['require-dev'] : 'No dependencies';

                $packages[] = [
                    'name' => $key,
                    'version' => $value,
                    'dependencies' => $dependencies,
                    'dev-dependencies' => $devDependencies
                ];
            }
        }

        return $packages;
    }
909337
private function getDependencies()
    {
        $dependencies = [];

        foreach ($this->resolver->names() as $name) {
            $dependencies[$name] = $this->getDependenciesRecursive($name);
        }

        return $dependencies;
    }
1027979
public static function getReportArray()
    {
        $composerArray = self::getComposerArray();
        $packages = self::getPackagesAndDependencies($composerArray['require']);
        $version = self::getDecomposerVersion($composerArray, $packages);

        $reportArray['Server Environment'] = self::getServerEnv();
        $reportArray['Laravel Environment'] = self::getLaravelEnv($version);
        $reportArray['Installed Packages'] = self::getPackagesArray($composerArray['require']);

        empty(self::getExtraStats()) ? '' : $reportArray['Extra Stats'] = self::getExtraStats();

        return $reportArray;
    }
1291361
protected function getPackageSortOrder()
    {
        $packageSortOrder = $this->getCachedValue('packageSortOrder');
        if ($packageSortOrder === false) {

            $data = $this->dataProvider->getData();

            // get flat list of package dependencies for each package
            $packageDependencies = array();
            foreach ($data as $packageId => $info) {
                if (!isset($packageDependencies[$packageId])) {
                    $packageDependencies[$packageId] = array();
                }
                $depends = $this->getDependsForPackage($packageId);
                $packageDependencies[$packageId] = array_merge(
                    $packageDependencies[$packageId],
                    $depends
                );
            }

            // build into a graph
            $graph = new Concentrate_Graph();
            $nodes = array();
            foreach ($packageDependencies as $packageId => $dependencies) {
                if ($packageId === '__site__') {
                    // special package '__site__' is not sorted with other
                    // packages. It gets put at the end.
                    continue;
                }
                if (!isset($nodes[$packageId])) {
                    $nodes[$packageId] = new Concentrate_Graph_Node(
                        $graph,
                        $packageId
                    );
                }
                foreach ($dependencies as $dependentPackageId) {
                    if ($dependentPackageId === '__site__') {
                        // special package '__site__' is not sorted with other
                        // packages. It gets put at the end.
                        continue;
                    }
                    if (!isset($nodes[$dependentPackageId])) {
                        $nodes[$dependentPackageId]
                            = new Concentrate_Graph_Node(
                                $graph,
                                $dependentPackageId
                            );
                    }
                }
            }
            foreach ($packageDependencies as $packageId => $dependencies) {
                foreach ($dependencies as $dependentPackageId) {
                    $nodes[$packageId]->connectTo($nodes[$dependentPackageId]);
                }
            }

            $sorter = new Concentrate_Graph_TopologicalSorter();
            try {
                $sortedNodes = $sorter->sort($graph);
            } catch (Concentrate_CyclicDependencyException $e) {
                throw new Concentrate_CyclicDependencyException(
                    'Package dependency order can not be determined because '
                    . 'package dependencies contain one more more cycles. '
                    . 'There is likely a typo in the package dependency '
                    . 'section of one or more YAML files.'
                );
            }

            $order = array();
            foreach ($sortedNodes as $node) {
                $order[] = $node->getData();
            }

            // special package __site__ is always counted last by default
            $order[] = '__site__';

            // return indexed by package id, with values being the relative
            // sort order
            $packageSortOrder = array_flip($order);

            $this->setCachedValue('packageSortOrder', $packageSortOrder);
        }

        return $packageSortOrder;
    }
246692
public function loadPackage($names)
    {
        $names = is_array($names) ? $names : func_get_args();

        foreach ($names as $name) {
            if (!array_key_exists($name, $this->packages)) {

                /** @var PackageInterface $package */
                if (!is_null($package = $this->manager->load($name))) {
                    $this->packages[$name] = $package;

                    if ($package->hasDependencies()) {
                        foreach ($package->getDependencies() as $dependency) {
                            $this->loadPackage($dependency);
                        }
                    }
                }
            }
        }

        return $this;
    }
384513
public function getArray()
    {
        $package = array(
            'name'=>$this->getName(),
            'version'=>$this->getVersion(),
            'relative_path'=>$this->getRelativePath(),
            'assets_path'=>$this->getAssetsPath(),
            'assets_presets'=>$this->getAssetsPresets(),
        );
        return $package;
    }
1309909
protected function getPackages()
    {
        if (! is_null($package = $this->input->getArgument('package'))) {
            if (Str::length($package) > 3) {
                $package = Str::snake($package, '-');
            } else {
                $package = Str::lower($package);
            }

            return array($package);
        }

        return $this->findAllAssetPackages();
    }
200753
protected function updatePackages($packagesFile = '')
    {
        $packagesFile = $packagesFile ?: "{$this->sageRoot}/package.json";
        $packages = json_decode(file_get_contents($packagesFile), true);
        if (!$this->addOn) {
            $packages = $this->removePresetsFromPackagesArray($packages);
        }
        $packages = $this->updatePackagesArray($packages);
        ksort($packages['devDependencies']);
        ksort($packages['dependencies']);
        file_put_contents(
            $packagesFile,
            preg_replace_callback('/^ +/m', function ($matches) {
                return str_repeat(' ', strlen($matches[0]) / 2);
            }, json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL)
        );
    }
42580
public function getPackagesThatDependOnPackage($slug)
    {
        $plugins = $this->getInstalledPlugins();
        $themes = $this->getInstalledThemes();
        $packages = array_merge($plugins->toArray(), $themes->toArray());

        $dependent_packages = [];

        foreach ($packages as $package_name => $package) {
            if (isset($package['dependencies'])) {
                foreach ($package['dependencies'] as $dependency) {
                    if (is_array($dependency) && isset($dependency['name'])) {
                        $dependency = $dependency['name'];
                    }

                    if ($dependency === $slug) {
                        $dependent_packages[] = $package_name;
                    }
                }
            }
        }

        return $dependent_packages;
    }
865177
protected function getDependsForPackage($packageId)
    {
        $cacheKey = 'packageDepends.'.$packageId;
        $packageDepends = $this->getCachedValue($cacheKey);
        if ($packageDepends === false) {
            $packageDepends = array();

            $data = $this->dataProvider->getData();
            if (isset($data[$packageId])) {
                $info = $data[$packageId];
                if (isset($info['Depends']) && is_array($info['Depends'])) {
                    $packageDepends = $info['Depends'];
                }
            }

            $this->setCachedValue($cacheKey, $packageDepends);
        }

        return $packageDepends;
    }
43393
public function getAvailablePackageStats(Package $package)
    {
        $result = [];
        $languagesDir = $package->getPackagePath() . '/' . DIRNAME_LANGUAGES;
        if ($this->fs->isDirectory($languagesDir)) {
            foreach ($this->fs->directories($languagesDir) as $localeDirectory) {
                $localeID = basename($localeDirectory);
                if (preg_match('/^[a-z]{2,3}($|_)/', $localeID)) {
                    $mo = $languagesDir . '/' . $localeID . '/LC_MESSAGES/messages.mo';
                    if ($this->fs->isFile($mo)) {
                        $result[$localeID] = $this->getMoFileStats($mo);
                    }
                }
            }
        }

        return $result;
    }
510828
protected function gatherLoadedPackagesHandles($packages)
    {
        $packages = (array) $packages;
        if (!$packages) {
            $plugins = $this->container->getPlugins();
            foreach ($plugins as $plugin) {
                $path = (new ReflectionClass($plugin))->getFileName();
                preg_match('/vendor\/([^\/]+)\/([^\/]+)/', $path, $handle);
                if (count($handle) !== 3) {
                    continue;
                }

                $packages[] = $handle[1].'/'.$handle[2];
            }
        }

        return $packages;
    }
475714
public function with($packages)
    {
        $packages = is_array($packages) ? $packages : func_get_args();

        $this->dependency = $packages;

        return $this;
    }
276041
protected function generateRequirePackages(array $packagePairs)
    {
        $requires = [];

        foreach ($packagePairs as $packagePair) {
            $requires[$packagePair->getName()] = $packagePair->getVersion();
        }

        return $requires;
    }
1094883
protected function getPackages()
	{
		if ( ! is_null($package = $this->input->getArgument('package')))
		{
			return array($package);
		}
		elseif ( ! is_null($bench = $this->input->getOption('bench')))
		{
			return array($bench);
		}

		return $this->findAllAssetPackages();
	}
1327569
public function resolveDependencies(array $dependencies, $params = null)
    {
        foreach ($dependencies as &$dependency) {
            if (is_null($dependency)) {
                $dependency = null;
            } else if ($dependency == 'array') {
                $dependency = [];
            } else {

                if ($this->provider->hasProvider($dependency)) {
                    $dependency = $this->provider->resolve($dependency, $params);
                } else {
                    $dependency = $this->make($dependency, $params);
                }
            }
        }

        return $dependencies;
    }
367026
public function getPackages()
    {
        if (null === $this->packages) {
            $this->packages = $this->findPackages();
        }

        return $this->packages;
    }