piedweb / composer-symlink
One Vendor Directory for multiple PHP projects using same dependencies - Disk space efficient composer fixer.
Requires
- php: >=8.4
- symfony/filesystem: ^7|^8
- thecodingmachine/safe: ^3
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v0.1.960
- v0.1.959
- v0.1.958
- v0.1.957
- v0.1.956
- v0.1.955
- v0.1.954
- v0.1.953
- v0.1.952
- v0.1.951
- v0.1.950
- v0.1.949
- v0.1.948
- v0.1.947
- v0.1.946
- v0.1.945
- v0.1.944
- v0.1.943
- v0.1.942
- v0.1.941
- v0.1.940
- v0.1.939
- v0.1.938
- v0.1.937
- v0.1.936
- v0.1.935
- v0.1.934
- v0.1.933
- v0.1.932
- v0.1.931
- v0.1.930
- v0.1.929
- v0.1.928
- v0.1.927
- v0.1.926
- v0.1.925
- v0.1.924
- v0.1.923
- v0.1.922
- v0.1.921
- v0.1.920
- v0.1.919
- v0.1.918
- v0.1.917
- v0.1.916
- v0.1.915
- v0.1.914
- v0.1.913
- v0.1.912
- v0.1.911
- v0.1.910
- v0.1.909
- v0.1.908
- v0.1.907
- v0.1.906
- v0.1.905
- v0.1.904
- v0.1.903
- v0.1.902
- v0.1.901
- v0.1.900
- v0.1.899
- v0.1.898
- v0.1.897
- v0.1.896
- 0.1.895
- 0.1.894
- 0.1.893
- 0.1.892
- 0.1.891
- 0.1.890
- 0.1.889
- 0.1.888
- 0.1.887
- 0.1.886
- 0.1.885
- 0.1.884
- 0.1.883
- 0.1.882
- 0.1.881
- 0.1.880
- 0.1.879
- 0.1.878
- 0.1.877
- 0.1.876
- 0.1.875
- 0.1.874
- 0.1.873
- 0.1.872
- 0.1.871
- 0.1.870
- 0.1.869
- 0.1.868
- 0.1.867
- 0.1.866
- 0.1.865
- 0.1.864
- 0.1.863
- 0.1.862
- 0.1.861
- 0.1.860
- 0.1.859
- 0.1.858
- 0.1.857
- 0.1.856
- 0.1.855
- 0.1.854
- 0.1.853
- 0.1.852
- 0.1.851
- 0.1.850
- 0.1.849
- 0.1.848
- 0.1.847
- 0.1.846
- 0.1.845
- 0.1.844
- 0.1.843
- 0.1.842
- 0.1.841
- 0.1.840
- 0.1.839
- 0.1.838
- 0.1.837
- 0.1.836
- 0.1.835
- 0.1.834
- 0.1.833
- 0.1.832
- 0.1.831
- 0.1.830
- 0.1.829
- 0.1.828
- 0.1.827
- 0.1.826
- 0.1.825
- 0.1.824
- 0.1.823
- 0.1.822
- 0.1.821
- 0.1.820
- 0.1.819
- 0.1.818
- 0.1.817
- 0.1.816
- 0.1.815
- 0.1.814
- 0.1.813
- 0.1.812
- 0.1.811
- 0.1.810
- 0.1.809
- 0.1.808
- 0.1.807
- 0.1.806
- 0.1.805
- 0.1.804
- 0.1.803
- 0.1.802
- 0.1.801
- 0.1.800
- 0.1.799
- 0.1.798
- 0.1.797
- 0.1.796
- 0.1.795
This package is auto-updated.
Last update: 2026-09-18 09:56:12 UTC
README
Composer Symlink
Disk efficient composer (fixer || symlinker) ➜ multiple projects relying on the same package version, why having multiple copies ?
This is a duplicate code killer to win some disk space.
Each vendor/{vendor}/{package} directory is moved to a shared
{globalVendorDir}/{vendor}/{package}-{version} and replaced by a symlink. Projects locking the
same version end up sharing a single copy; projects locking different versions keep their own.
Install
Via Packagist
Create a new project and install the dependency
mkdir composer-dependencies && cd composer-dependencies composer require piedweb/composer-symlink
Usage
Create cs.php
<?php use PiedWeb\ComposerSymlink\ComposerSymlink; include 'vendor/autoload.php'; (new ComposerSymlink( [ '/path/to/my/project', '/path/to/my/second/project', ], '/path/to/composer-dependencies/global-vendor' ))->exec();
Then run it after each composer update:
php cs.php
You can also wire it in the post-update-cmd script of each project:
{
"scripts": {
"post-update-cmd": "php /path/to/composer-dependencies/cs.php"
}
}
Arguments
| Argument | Description |
|---|---|
$projectPathList |
Every project sharing the global vendor directory. Each one needs a vendor/ directory and a composer.lock. |
$globalVendorDir |
Absolute path of the shared vendor directory. Created on demand. A relative path throws. |
$pruneUnused |
true by default: shared packages no longer referenced are deleted. |
The project list must be exhaustive
Pruning is what reclaims the disk space, and it decides what to delete from the global vendor
directory alone — it has no way to discover a project you did not list. Leaving a project out
deletes the packages it still symlinks, and its vendor/ is left with dangling links until the
next composer install.
So either list every project sharing the directory, or pass pruneUnused: false and clean up
by hand:
(new ComposerSymlink([$projectPath], '/path/to/global-vendor', pruneUnused: false))->exec();
What is left alone
vendor/composer/,vendor/bin/and the files at the root ofvendor/.- Packages absent from
composer.lock(path repositories, hand-vendored code): without a version there is nothing to key a shared copy on. - Packages already symlinked. The link target wins over
composer.lock, so a lock bumped without a matchingcomposer installnever invalidates the copy the project actually uses.
Contributing
Please see contributing
Credits
License
The MIT License (MIT). Please see License File for more information.