https://github.com/hichemtab-tech/pomposer
A fast, caching-based alternative to Composer β with global storage and shared dependencies across PHP projects.
https://github.com/hichemtab-tech/pomposer
composer package-manager php php-library
Last synced: 12 months ago
JSON representation
A fast, caching-based alternative to Composer β with global storage and shared dependencies across PHP projects.
- Host: GitHub
- URL: https://github.com/hichemtab-tech/pomposer
- Owner: HichemTab-tech
- License: mit
- Created: 2025-07-06T19:17:32.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2025-07-15T00:50:52.000Z (12 months ago)
- Last Synced: 2025-07-15T04:48:11.606Z (12 months ago)
- Topics: composer, package-manager, php, php-library
- Language: PHP
- Homepage:
- Size: 477 KB
- Stars: 15
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Pomposer - Shared Package Manager for PHP (pnpm-style for PHP)
A proof-of-concept package manager for PHP that installs dependencies once and shares them globally across projects to save space and boost speed. Inspired by pnpm, Pomposer avoids duplication by linking packages instead of reinstalling them for every project.

## Why Pomposer?
Composer is the backbone of modern PHP development, but it's not optimized for shared storage.
Every `composer install` duplicates packages per project, eating up disk space and time.
**Pomposer** brings the best of `pnpm` to PHP:
- π¦ **Global Package Store**: Each package version is downloaded and stored *only once*.
- β‘ **Faster Installs**: Once a package is in the global store, installs are nearly instant.
- βοΈ **Advanced Autoloader**: Generates a complete, optimized autoloader (PSR-4, classmap, files).
- π€ **Framework Compatibility**: Creates the necessary manifests (`installed.json`, etc.) for features like Laravel's package auto-discovery.
- π **Script Execution**: Correctly runs `post-install-cmd` and `post-autoload-dump` scripts.
---
## How It Works
1. **Read `composer.lock`** (or falls back to `composer.json` with its own resolver).
2. **Download and cache packages** to the global store at `~/.pomposer-store`.
3. **Read the full `composer.json` from within each package** to gather all metadata (autoloading rules, scripts, and framework providers).
4. **Generate a complete vendor directory**, including:
- An optimized classmap and PSR-4 autoloader pointing to the global store.
- The full package manifest (`installed.json`, `installed.php`, etc.) for framework compatibility.
- Compatibility stubs for Composer's internal classes.
5. **Execute post-install scripts** to finalize the installation (e.g., `php artisan package:discover`).
---
## Installation
You can install Pomposer globally or locally via Composer:
```bash
composer global require hichemtab-tech/pomposer
```
Make sure Composer global bin is in your `$PATH`. Then run:
```bash
pomposer install
```
---
## Example 1: Build a small Project with Pomposer
Letβs test Pomposer using a simple PHP app that:
* Uses `monolog/monolog` for logging
* Uses your custom package `hichemtab-tech/namecrement`
* Has its own PSR-4 autoloading
---
### 1. Create your test project
```bash
mkdir test-pomposer && cd test-pomposer
```
### 2. Create a `composer.json`:
```json
{
"name": "hichemtab-tech/test-pomposer",
"autoload": {
"psr-4": {
"HichemTabTech\\TestPomposer\\": "src/"
}
},
"authors": [
{
"name": "HichemTab-tech",
"email": "konanhichemsinshi@gmail.com"
}
],
"require": {
"hichemtab-tech/namecrement": "^1.1",
"monolog/monolog": "^3.9"
}
}
```
### 3. Create your source and test files
```bash
mkdir src
touch src/index.php
```
Then edit `src/index.php`:
```php
pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
$log->info('Pomposer is alive!');
```
### 4. Run Pomposer
```bash
pomposer install
```
It will:
* Resolve dependencies (even if no `composer.lock`)
* Download and cache each package version in `~/.pomposer-store`
* Link the necessary packages into your `vendor/` folder
* Generate a working autoloader
### 5. Run the test script
```bash
php src/index.php
```
β
You should see output like:
```
Next unique file name after the list of existing files:
Existing files: file, file (1), file (2)
New file name: file (3)
[2025-07-06 20:31:22] test.INFO: Pomposer is alive! []
```
β
You just installed `monolog/monolog` without Composer touching your `vendor/` at all.
## Example: Building a Real Laravel App with Pomposer
We have adapted Pomposer to install and run a modern Laravel application.
This process served as a practical test of its ability to handle complex dependencies, package auto-discovery, and post-install scripting.
### 1. Create a Laravel Project
First, create a standard Laravel project with a starter kit like Breeze.
#### using Laravel Installer
```bash
# Example using Laravel Breeze with React & SSR
laravel new pomposer-test-app --breeze --stack react --ssr
cd pomposer-test-app
```
#### or using [LaravelFS Installer](https://github.com/HichemTab-tech/LaravelFS)
```bash
laravelfs new pomposer-test-app --breeze --stack react --ssr
cd pomposer-test-app
```
### 2. Remove Existing Vendor Directory
We want to install from scratch using only Pomposer.
```bash
rm -rf vendor composer.lock
```
### 3. Run Pomposer
Now, tell Pomposer to handle the installation.
```bash
pomposer install
```
Pomposer will resolve dependencies, use its global cache, generate the autoloader and package manifests, and correctly run php artisan package:discover as part of its script execution.
### 4. Verify It Works
Once the installation is complete, you can run standard Artisan commands. The application is ready to go.
```bash
php artisan about
```
You will see a complete list of environment details and discovered packages (like Inertia), proving that Laravel has booted successfully using the Pomposer-generated vendor directory.
## Global Store Layout
Packages are stored by name + version:
```
βββ ~/.pomposer-store/
βββ hichemtab-tech
β βββ namecrement
β βββ 1.1.0
β βββ composer.json
β βββ src
βββ monolog
β βββ monolog
β βββ 3.9.0
β βββ composer.json
β βββ src
βββ psr
βββ log
βββ 3.0.2
βββ composer.json
βββ src
```
---
## β οΈ Limitations (Beta Notice)
> [!WARNING]
> Pomposer is still in **beta** β built as a proof of concept.
Current limitationsΒ :
* β οΈ **No Symlinking:** Unlike pnpm, Pomposer does not use symlinks. It generates an autoloader that points directly to the global store. This means the `vendor/` directory is mostly empty, which can break tools or build scripts that expect to find physical files there.
* β οΈ **Basic Dependency Resolver:** The dependency resolver is simple and may fail on complex version constraints. It works best when a `composer.lock` file is present.
* β **No Support for `provide`/`replace`/`conflict`:** These advanced dependency management rules are not implemented.
* β **No Composer Plugin System:** Cannot run Composer plugins.
* β οΈ **Limited Autoloading:** Does not support the deprecated `psr-0` standard.
---
## π‘ Want to Contribute?
Got ideas or experience with Composer internals? Want to help evolve Pomposer into something production-ready?
π **Join the discussion and contribute on GitHub**:
[https://github.com/HichemTab-tech/pomposer/discussions/4](https://github.com/HichemTab-tech/pomposer/discussions/4)
---
## License
MIT Β© @HichemTab-tech