composer / satis

Simple static Composer repository generator - For a full private Composer repo use Private Packagist
MIT License
3.14k stars 519 forks source link

Add repository dynamically #112

Closed dtr0yan closed 8 years ago

dtr0yan commented 10 years ago

Hi Can you implement adding repository to satis dynamically? I mean when someone request package that not exists in satis it will add this package automatically. Thanks

max-voloshin commented 10 years ago

I am not sure that I understood you, but satis definitely can't add any packages after packages.json was created, because it is static file.

If you want determine sources for satis before creating packages.json dynamically - just generate satis's config.json "on fly" relying on your custom logic.

ThYpHo0n commented 10 years ago

I'm also interested in this feature. Are there any updates on this from someone else? Maybe we can add a process to add the new package/repository to packages.json and then reload (the necessary parts of) satis, but the main interesting part is how to keep the connection for that time alive or force a retry for the initial composer request to satis...

Update: I thought once more about this and i don't have a clue to integrate it in a good way. Satis is just a construction of satic file files (packages.json, dist files). Composer is just pulling the packages.json from Satis to fetch all available packages from it without telling Satis which packages he's looking for. Possible solution: First you create a Satis "Server" which rebuilds itself after he's getting special requests for packages he doesn't have at this time. Then you add custom logic to Composer to tell Satis which packages it's looking for. I think i don't need to say that this is really bad because we need to touch the Composer src and implement server logic on Satis but right now i don't know a better solution because both Composer & Satis are not designed in a way to add repositories dynamically :/

glensc commented 10 years ago

I implemented with a bit shell scripting (because it was quick, probably ideal would be new Command in satis)

the workflow is:

so this allows kind of dynamically add new repos, and rebuild (satis invoked) are only when for one repo at a time

antonrubtsov commented 10 years ago

This feature name is caching proxy. Here is an article. http://code.tutsplus.com/tutorials/setting-up-a-local-mirror-for-composer-packages-with-satis--net-36726 Hope it helps

samsamm777 commented 9 years ago

+1

alcohol commented 8 years ago

This is virtually impossible since there is no way Satis can determine what the source should be for the missing package.

debugteam commented 7 years ago

This is virtually impossible since there is no way Satis can determine what the source should be for the missing package.

Reading this and beeing confronted with the same problem, i actually see a solution:

I would recommend integrating a command into composer like this:

php composer.phar configure-proxy

It should read the composer.json, search for composer repositories (other than packagist.org) and send the composer.json via REST API.

An input-argument like "api" could be used to set a specific server upload location. e.g.:

php composer.phar configure-proxy api=http://path-to-satis.tld/upload/

Since there is allready some code to be used to analyze the composer.json here:

https://code.tutsplus.com/tutorials/setting-up-a-local-mirror-for-composer-packages-with-satis--net-36726

...i think i could make that happen.

Any ideas or comments?

@Seldaek @jadb @niksamokhvalov @naderman @johnstevenson @alcohol

alcohol commented 7 years ago

If you can come up with an implementation that does not involve modifying Composer, I would be open to hearing more about it. But anything that involves modifying Composer has a no vote from my perspective. Satis should operate independently of Composer, and Composer should know nothing about how Satis operates. Composer sees it as nothing more than a provider of metadata, just like Packagist.

debugteam commented 7 years ago

Of course one could just run a script to update the cache like:

composer run-script pre-package-install

The defined script could as well upload the composer.json

planktonfun commented 7 years ago

Is there a way to cache dump-autoloading result, it makes sense to cache it when no commit updates occured from the composer.lock file. basically: 1st step: composer update // write lock file, generate autoload file 2nd step: composer update // read lock file, if no folders|vendors changes and autoload exist, do not generate autoload file