-
-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ask questions in interact, install depends automatically, cleanup
- Loading branch information
Showing
4 changed files
with
217 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony MakerBundle package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\MakerBundle\Maker\Common; | ||
|
||
use Symfony\Bundle\MakerBundle\ConsoleStyle; | ||
use Symfony\Component\Process\Process; | ||
|
||
trait InstallDependencyTrait | ||
{ | ||
/** | ||
* @param string $composerPackage Fully qualified composer package to install e.g. symfony/maker-bundle | ||
*/ | ||
public function installDependencyIfNeeded(ConsoleStyle $io, string $expectedClassToExist, string $composerPackage): ConsoleStyle | ||
{ | ||
if (class_exists($expectedClassToExist)) { | ||
return $io; | ||
} | ||
|
||
$io->writeln(sprintf('Running: composer require %s', $composerPackage)); | ||
|
||
Process::fromShellCommandline(sprintf('composer require %s', $composerPackage))->run(); | ||
|
||
$io->writeln(sprintf('%s successfully installed!', $composerPackage)); | ||
$io->newLine(); | ||
|
||
return $io; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.