mirror of
https://github.com/flarum/framework.git
synced 2025-02-22 13:08:40 +08:00
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace SychO\PackageManager;
|
|
|
|
use Composer\Config;
|
|
use Composer\Console\Application;
|
|
use Flarum\Foundation\AbstractServiceProvider;
|
|
use Flarum\Foundation\Paths;
|
|
use Illuminate\Contracts\Container\Container;
|
|
|
|
class PackageManagerServiceProvider extends AbstractServiceProvider
|
|
{
|
|
public function register()
|
|
{
|
|
$this->container->singleton(Application::class, function (Container $container) {
|
|
// This should only ever be resolved when running composer commands,
|
|
// because we modify other environment configurations.
|
|
$composer = new Application();
|
|
$composer->setAutoExit(false);
|
|
|
|
$paths = $container->make(Paths::class);
|
|
|
|
putenv("COMPOSER_HOME={$paths->storage}/.composer");
|
|
putenv("COMPOSER={$paths->base}/composer.json");
|
|
Config::$defaultConfig['vendor-dir'] = $paths->base.'/vendor';
|
|
|
|
// When running simple require, update and remove commands on packages,
|
|
// composer 2 doesn't really need this much unless the extensions are very loaded dependency wise,
|
|
// but this is necessary for running flarum updates.
|
|
@ini_set('memory_limit', '1G');
|
|
@set_time_limit(5 * 60);
|
|
|
|
return $composer;
|
|
});
|
|
|
|
$this->container->alias(Application::class, 'flarum.composer');
|
|
}
|
|
}
|