Helpers Collection
Visit this package on GitHub

Composer Class

By default, this package using the project path.

Get composer.json content as array:

use NormanHuth\Helpers\Composer;
 
return Composer::getComposerJsonData();
 
/* // ...
{
"name": "norman-huth/helpers-collection-php",
"license": "MIT",
"authors": [
{
"name": "Norman Huth",
"homepage": "https://huth.it"
}
],
"autoload": {
"psr-4": {
"NormanHuth\\Helpers\\": "src/"
},
"files": [
"functions/helpers.php"
]
},
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0",
"league/commonmark": "^2.2",
"ext-mbstring": "*",
"ext-zip": "*"
},
"minimum-stability": "dev"
}
*/

Get locks dependencies:

use NormanHuth\Helpers\Composer;
 
return Composer::getLockDependencies();
 
/* // ...
{
"dflydev/dot-access-data": "dev-main",
"doctrine/inflector": "2.1.x-dev",
"illuminate/collections": "10.x-dev",
"illuminate/conditionable": "10.x-dev",
"illuminate/contracts": "10.x-dev",
"illuminate/macroable": "10.x-dev",
"illuminate/support": "10.x-dev",
"league/commonmark": "dev-main",
"league/config": "dev-main",
"nesbot/carbon": "dev-master",
"nette/schema": "v1.2.x-dev",
"nette/utils": "dev-master",
"psr/container": "dev-master",
"psr/event-dispatcher": "dev-master",
"psr/simple-cache": "dev-master",
"symfony/deprecation-contracts": "dev-main",
"symfony/polyfill-mbstring": "dev-main",
"symfony/polyfill-php80": "dev-main",
"symfony/translation": "6.3.x-dev",
"symfony/translation-contracts": "dev-main",
"voku/portable-ascii": "2.0.1"
}
*/

Get locks development dependencies:

use NormanHuth\Helpers\Composer;
 
return Composer::getLockDevDependencies();
 
/*
{
"phpunit/phpunit": "^10.0"
}
*/

Add or update a package requirement to composer.json:

use NormanHuth\Helpers\Composer;
 
Composer::require('vendor/package', '^1.0.0');

Add or update a package development requirement to composer.json:

use NormanHuth\Helpers\Composer;
 
Composer::require('vendor/package', '^1.0.0');

Remove a package requirement from composer.json:

use NormanHuth\Helpers\Composer;
 
Composer::remove('vendor/package');

Remove a package development requirement from composer.json:

use NormanHuth\Helpers\Composer;
 
Composer::removeDev('vendor/package');

Get composer.lock content as array:

use NormanHuth\Helpers\Composer;
 
Composer::getComposerLockData();

Check if package is in requirements:

use NormanHuth\Helpers\Composer;
 
return Composer::isRequire('vendor/package');
 
// false
// ^1.0.0

Check if package is in development requirements:

use NormanHuth\Helpers\Composer;
 
return Composer::isRequireDev('vendor/package');
 
// false
// ^1.0.0

Get the name of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getName();
 
// norman-huth/helpers-collection-php

Get the name of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getDescription();
 
// Lorem Ipsum

Get the license of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getLicense();
 
// MIT

Get the homepage of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getHomepage();
 
// https://huth.it

Get the requirements of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getRequirements();
 
/*
{
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0",
"league/commonmark": "^2.2",
"ext-mbstring": "*",
"ext-zip": "*"
}
*/

Get the development requirements of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getDevRequirements();
 
/*
{
"phpunit/phpunit": "^10.0"
}
*/

Get the minimum stability of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getStability();
 
// "stable"

Get autoload mappings:

use NormanHuth\Helpers\Composer;
 
return Composer::getAutoload();
 
/*
{
"psr-4": {
"NormanHuth\\Helpers\\": "src/"
},
"files": [
"functions/helpers.php"
]
}
*/

Get PSR-4 autoload mappings:

use NormanHuth\Helpers\Composer;
 
return Composer::getAutoloadPSR4();
 
/*
{
"NormanHuth\\Helpers\\": "src/"
}
*/

Get autoloaded files:

use NormanHuth\Helpers\Composer;
 
return Composer::getAutoloadFiles();
 
/*
{
"functions/helpers.php"
}
*/

Get development autoload mappings:

use NormanHuth\Helpers\Composer;
 
return Composer::getDevAutoload();
 
/*
{
"psr-4": {
"NormanHuth\\Helpers\\": "src/"
},
"files": [
"functions/helpers.php"
]
}
*/

Get PSR-4 development autoload mappings:

use NormanHuth\Helpers\Composer;
 
return Composer::getDevAutoloadPSR4();
 
/*
{
"NormanHuth\\Helpers\\": "src/"
}
*/

Get autoloaded development files:

use NormanHuth\Helpers\Composer;
 
return Composer::getDevAutoloadFiles();
 
/*
{
"functions/helpers.php"
}
*/

Get the keywords of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getKeywords();
 
/*
{
"php",
"laravel"
}
*/

Get the configuration of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getKeywords();

Get the configuration of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getExtras();

Get the scripts of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getScripts();

Get the repositories of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getRepositories();

Get the authors of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getAuthors();

Get the vendor name of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getVendor();

Get the package name of the package:

use NormanHuth\Helpers\Composer;
 
return Composer::getPackage();

Return installed version composer package version via lock file:

use NormanHuth\Helpers\Composer;
 
return Composer::getLockedVersion();
 
// "1.0.14"
// null

Set different composer package path:

use NormanHuth\Helpers\Composer;
 
Composer::setProjectPath(base_path('vendor/package'));