Easily parse your project's Composer configuration, and those of its dependencies, at runtime

Overview

Composed

Code Quality

This library provides a set of utility functions designed to help you parse your project's Composer configuration, and those of its dependencies, at runtime.

Usage

The API combines functional and object-oriented approaches.

Locate the vendor directory

(Chicken and egg...)

$absoluteVendorPath = Composed\VENDOR_DIR;

Locate the project's base directory

$absoluteProjectPath = Composed\BASE_DIR;

Get the authors of a specific package

You can fetch data from the composer.json file of a specific package.

$authors = Composed\package_config('phpunit/phpunit', 'authors');

assert($authors === [
    [
        'name' => "Sebastian Bergmann",
        'email' => "[email protected]",
        'role' => "lead",
    ],
]);

Get licenses of all installed packages

You can fetch data from all composer.json files in your project in one go.

$licenses = Composed\package_configs('license');

assert($licenses === [
  'joshdifabio/composed' => "MIT",
  'doctrine/instantiator' => "MIT",
  'phpunit/php-code-coverage' => "BSD-3-Clause",
]);

Get the absolute path to a file in a package

$path = Composed\package('phpunit/phpunit')->getPath('composer.json');

Get all packages installed on your project

foreach (Composed\packages() as $packageName => $package) {
    $pathToPackageConfig = $package->getPath('composer.json');
    // ...
}

Get data from your project's Composer config

You can also fetch data from the composer.json file located in your project root.

$projectAuthors = Composed\project_config('authors');

assert($projectAuthors === [
    [
        'name' => 'Josh Di Fabio',
        'email' => '[email protected]',
    ],
]);

Installation

Install Composed using composer.

composer require joshdifabio/composed

Credits

Credit goes to @igorw whose get-in library is partially copied into this library. Unfortunately, igorw/get-in requires PHP 5.4 while Composed aims for PHP 5.3 compatibility.

License

Composed is released under the MIT license.

You might also like...
Staggered import of large and very large MySQL Dumps even through the web servers with hard runtime limit and those in safe mode.

Staggered import of large and very large MySQL Dumps (like phpMyAdmin dumps) even through the web servers with hard runtime limit and those in safe mode. | Persian Translation Version

Merge one or more additional composer.json files at Composer runtime

Composer Merge Plugin Merge multiple composer.json files at Composer runtime. Composer Merge Plugin is intended to allow easier dependency management

A Composer tool to show unused Composer dependencies by scanning your code.
A Composer tool to show unused Composer dependencies by scanning your code.

composer-unused A Composer tool to show unused Composer dependencies by scanning your code. Created by Andreas Frömer and contributors, logo by Caneco

These projects are free for public use. Be a lesson for those who violate the rights of others!! ✌️

Faraz Kish Projects These projects are free for public use. Be a lesson for those who violate the rights of others!! ✌️ Brands Farazkish Uinvest MFina

Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace

Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace, in order to prevent conflicts with other plugins loading the same dependencies in different versions.

Easily add all the 58 Algerian Wilayas and its Dairas to your cool Laravel project (Migrations, Seeders and Models).
Easily add all the 58 Algerian Wilayas and its Dairas to your cool Laravel project (Migrations, Seeders and Models).

Laravel-Algereography Laravel-Algereography allows you to add Migrations, Seeders and Models of Algerian Wilayas and Dairas to your existing or new co

Composer bin plugin — Isolate your bin dependencies

Composer bin plugin — Isolate your bin dependencies Table of Contents Why? How does this plugin work? Installation Usage Example The all bin namespace

:date: The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects

sabre/vobject The VObject library allows you to easily parse and manipulate iCalendar and vCard objects using PHP. The goal of the VObject library is

A composer plugin, to install differenty types of composer packages in custom directories outside the default composer default installation path which is in the vendor folder.

composer-custom-directory-installer A composer plugin, to install differenty types of composer packages in custom directories outside the default comp

Composer registry manager that help to easily switch to the composer repository you want

CRM - Composer Registry Manager Composer Registry Manager can help you easily and quickly switch between different composer repositories. 简体中文 Install

Simplexcel.php - Easily read / parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc spreadsheet tabular file formats

Simple Excel Easily parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc formats For further deatails see the GitHuib P

Shade/Inject composer dependencies into PocketMine-MP plugins.

ComposerShader README for v0.2.0-dev Important Note: This is not perfect, nor will it ever be, with several checks for common uses of certain function

Detect unused composer dependencies
Detect unused composer dependencies

Project scanner for detect unused composer dependencies Versions Use 1.3.x@dev versions for projects with php 5.6, 7.0 Use 2.x versions for projects w

This composer plugin is a temporary implementation of using symbolic links to local packages as dependencies to allow a parallel work process

Composer symlinker A Composer plugin to install packages as local symbolic links. This plugin is a temporary implementation of using symbolic links to

Plugin for composer to apply patches onto dependencies.

composer-patches-plugin This plugin allows you to provide patches for any package from any package. If you don't want a patch package outside the root

This composer plugin allows you to share your selected packages between your projects by creating symlinks
This composer plugin allows you to share your selected packages between your projects by creating symlinks

Composer - Shared Package Plugin This composer plugin allows you to share your selected packages between your projects by creating symlinks. All share

Laravel Admin Dashboard, Admin Template with Frontend Template, for scalable Laravel projects. It is to save your time when You start with new scalable Laravel projects with many features Bootstrap, cooreui, infyom admin Generator, roles and  permissions, translatable models, spatie media and much more GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...
GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...

Setup PHP in GitHub Actions Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in GitHub

GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...
GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...

Setup PHP in GitHub Actions Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in GitHub

Comments
  • Call to undefined function Composed\Internal\is_dir()

    Call to undefined function Composed\Internal\is_dir()

    Hey! Good day and many thanks for such a useful package.

    I have this error on my server:

    2022/08/12 05:32:52 [error] 212035#212035: *2678 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Composed\Internal\is_dir() in /var/www/html/vendor/joshdifabio/composed/src/functions_internal.php:8
    Stack trace:
    #0 /var/www/html/vendor/joshdifabio/composed/src/functions.php(4): Composed\Internal\findVendorDir()
    #1 /var/www/html/vendor/joshdifabio/composed/src/functions_include.php(5): require('...')
    #2 /var/www/html/vendor/composer/autoload_real.php(55): require('...')
    #3 /var/www/html/vendor/composer/autoload_real.php(38): composerRequirec1a531d1a43acaf030c072cc82c406dd()
    #4 /var/www/html/vendor/autoload.php(12): ComposerAutoloaderInitc1a531d1a43acaf030c072cc82c406dd::getLoader()
    #5 /var/www/html/public/index.php(24): require('...')
    #6 {main}
      thrown in /var/www/html/vendor/joshdifabio/composed/src/functions_internal.php on line 8" while reading response header from upstream, client: 138.68.103.14, server: ********, request: "GET /en HTTP/2.0", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "********"
    2022/08/12 05:33:23 [error] 212035#212035: *2678 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Composed\Internal\is_dir() in /var/www/html/vendor/joshdifabio/composed/src/functions_internal.php:8
    

    Result is error 500 rendered in browser directly (Nginx level, not a soft PHP/Laravel error page).

    PHP: PHP 8.1.8 (cli) (built: Jul 11 2022 08:30:39) (NTS)
    Nginx: nginx/1.19.5

    Laravel: 8.83.23
    Laravel Nova: 3.32.0


    I've recently switched to PHP 8.1 from 8.0. Not sure if it's related or not, but before the upgrade didn't ever see such an issue.

    opened by jangaraev 0
Releases(v1.0.0)
Owner
Josh Di Fabio
Josh Di Fabio
Merge one or more additional composer.json files at Composer runtime

Composer Merge Plugin Merge multiple composer.json files at Composer runtime. Composer Merge Plugin is intended to allow easier dependency management

Wikimedia 844 Dec 5, 2022
Simple static Composer repository generator - For a full private Composer repo use Private Packagist

Satis Simple static Composer repository generator. Run from source Satis requires a recent PHP version, it does not run with unsupported PHP versions.

Composer 2.9k Jan 3, 2023
:musical_note: Provides a composer plugin for normalizing composer.json.

composer-normalize Provides a composer plugin for normalizing composer.json. Why When it comes to formatting composer.json, you have the following opt

null 861 Jan 4, 2023
Simple composer script to manage phar files using project composer.json.

tooly-composer-script With tooly composer-script you can version needed PHAR files in your project's composer.json without adding them directly to a V

Tommy Mühle 100 Sep 27, 2022
Satis-go is a web server for hosting and managing your Satis Repository for Composer Packages

Satis-go download latest Satis-go is a web server for hosting and managing your Satis Repository for Composer Packages Some Highlights: Satis-go provi

Ben Schwartz 99 Aug 1, 2022
composer parallel install plugin

prestissimo (composer plugin) This is a composer 1.x plugin that downloads packages in parallel to speed up the installation process. Announcement: Co

Hiraku NAKANO 6.3k Dec 25, 2022
Patch other composer packages on install or update

patch-installer Patch other composer packages on install or update. experimental feature Usage For a patch type change the install path to vendor dire

Maik Penz 49 Apr 11, 2021
A no-frills PsySH-Composer plugin

uma/composer-psysh A no-frills PsySH-Composer plugin. In a nutshell, it provides a composer psy subcommand that spawns a Psy Shell with autoload integ

Marcel Hernandez 18 May 23, 2022
A CLI tool to check whether a specific composer package uses imported symbols that aren't part of its direct composer dependencies

A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. This will prevent you from using "soft" dependencies that are not defined within your composer.json require section.

Matthias Glaub 722 Dec 30, 2022
Check your Composer dependencies at runtime.

Composition Composition provides a lightweight and generic API, that you can use to check your environment at runtime, instead of manually go checking

Bilal Amarni 108 May 4, 2021