Skip to content

Instantly share code, notes, and snippets.

@webdev23
Created October 8, 2025 00:35
Show Gist options
  • Select an option

  • Save webdev23/64f4f6875ed6b40ca2e8f8d486b04419 to your computer and use it in GitHub Desktop.

Select an option

Save webdev23/64f4f6875ed6b40ca2e8f8d486b04419 to your computer and use it in GitHub Desktop.
PHP decomposer | Convert composer packages to a single flat file directly usable.

This wonderful tool allow to render a PHP composer package as a single PHP file.

https://github.com/cubiclesoft/php-decomposer

Here is a bash script to speed-up things.

It allow to get the final needed file from the current directory in few seconds, without never messing with composer.

Usage example (Find a package and it's documentation at https://packagist.org/packages)

From your project, or any directory:

decomposer 'intervention/image'

Yield a file intervention-image.php directly usable, in the current dir.

Install

Assuming ~/.local/bin is declared in your $PATH

If not https://getcomposer.org/download/

php -r "if (hash_file('sha384', 'composer-setup.php') === 'ed0feb545ba87161262f2d45a633e34f591ebb3381f2e0063c345ebea4d228dd0043083717770234ec00c5a9f9593792') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar ~/.local/bin

Assuming php-decomposer is installed in ~/APPS/php-decomposer/

decomposer script

DIR=$PWD
cd ~/APPS/php-decomposer/
rm -rf projects/"$(echo $1 | sed s:/:-:g)"
php decomposer.php create $1
cd  projects/"$(echo $1 | sed s:/:-:g)"
echo projects/"$(echo $1 | sed s:/:-:g)"
composer require $1
php decompose.php all
cd final
cp $(ls | grep php) $DIR/$(echo $1 | sed s:/:-:g).php

Move the script to ~/.local/bin

mv decomposer ~/.local/bin


Enjoy composerless devellopment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment