Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add composer path config #75

Merged
merged 4 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/paket.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@

'base_uri' => env('PAKET_BASE_URI', 'paket'),

/*
|--------------------------------------------------------------------------
| Composer PATH
|--------------------------------------------------------------------------
|
| to change this path to anything your composer location.
|
*/

'composer_path' => env('PAKET_COMPOSER_PATH', '/usr/bin/composer'),

/*
|--------------------------------------------------------------------------
| Paket Route Middlewares
Expand Down
3 changes: 2 additions & 1 deletion src/PaketServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ private function registerBindings(): void
return new Composer(
$this->app->make(Filesystem::class),
base_path(),
storage_path('paket/jobs')
storage_path('paket/jobs'),
Config::get('paket.composer_path', '/usr/bin/composer')
);
});

Expand Down
15 changes: 12 additions & 3 deletions src/Support/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,27 @@ final class Composer
*/
private $loggingPath;

/**
* The composer location path.
*
* @var string
*/
private $composerPath;

/**
* Create a new Composer manager instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param string $workingPath
* @param string $loggingPath
* @param string $composerPath
*/
public function __construct(Filesystem $files, string $workingPath, string $loggingPath)
public function __construct(Filesystem $files, string $workingPath, string $loggingPath, string $composerPath)
{
$this->files = $files;
$this->workingPath = $workingPath;
$this->loggingPath = $loggingPath;
$this->composerPath = $composerPath;
}

/**
Expand Down Expand Up @@ -102,7 +111,7 @@ public function install(RequirementContract $requirement, JobContract $job): voi

$command = sprintf(
'%s require %s %s',
'/usr/bin/composer',
$this->composerPath,
$requirement,
implode(' ', $flags)
);
Expand Down Expand Up @@ -131,7 +140,7 @@ public function uninstall(RequirementContract $requirement, JobContract $job): v

$command = sprintf(
'%s remove %s %s',
'/usr/bin/composer',
$this->composerPath,
$requirement->getName(),
implode(' ', $flags)
);
Expand Down