Install Project command #322

Merged
merged 8 commits into from Mar 8, 2012

Conversation

Projects
None yet
5 participants
Contributor

beberlei commented Feb 19, 2012

This PR adds a new command "install-project". It creates a new directory and downloads a given package + version into this directory as skeleton for a new project for example. You can also use it to check out a development version of any package without knowing where exactly the VCS is located by using "--prefer-source". It allows to configure the packagist url or use a packages.json directly.

@stof stof commented on an outdated diff Feb 19, 2012

doc/create-projects.md
@@ -0,0 +1,16 @@
+# Create Projects
+
+You can use Composer to create new projects from existing packages. There are several applications for this:
+
+1. You can deploy application packages.
+2. You can check out any package and start developing on patches for example.
+3. Projects with multiple developers can use this feature to bootstrap the initial application for development.
+
+To create a new project using composer you can use the "install-project", pass it a package name + version and a directory to create the project in. The directory is not allowed to exist, it will be created during installation.
+
+ php composer.phar install-project doctrine/orm 2.2.0 /path/to/new-project
+
+By default the command checks for the packages on packagist.org. To change this behavior you can use the --repository-url parameter and either point it to an HTTP url for your own packagist repository or to a packages.json file.
+
+If you want to get a development version of the code directly checked out from version control you have to add the --prefer-source parameter.
@stof

stof Feb 19, 2012

Contributor

can you wrap the lines please ?

@stof stof commented on an outdated diff Feb 19, 2012

src/Composer/Command/InstallProjectCommand.php
+ $input->getArgument('package'),
+ $input->getArgument('directory'),
+ $input->getArgument('version'),
+ (Boolean)$input->getOption('prefer-source'),
+ $input->getOption('repository-url')
+ );
+ }
+
+ public function installProject(IOInterface $io, $packageName, $directory = null, $version = null, $preferSource = false, $repositoryUrl = null)
+ {
+ $dm = $this->createDownloadManager($io);
+ if ($preferSource) {
+ $dm->setPreferSource(true);
+ }
+
+ if ($repositoryUrl === null) {
@stof

stof Feb 19, 2012

Contributor

this should use a yoda condition (same for next ones)

@stof stof commented on an outdated diff Feb 19, 2012

src/Composer/Command/InstallProjectCommand.php
+ $input->getArgument('version'),
+ (Boolean)$input->getOption('prefer-source'),
+ $input->getOption('repository-url')
+ );
+ }
+
+ public function installProject(IOInterface $io, $packageName, $directory = null, $version = null, $preferSource = false, $repositoryUrl = null)
+ {
+ $dm = $this->createDownloadManager($io);
+ if ($preferSource) {
+ $dm->setPreferSource(true);
+ }
+
+ if ($repositoryUrl === null) {
+ $sourceRepo = new ComposerRepository(array('url' => 'http://packagist.org'));
+ } else if (substr($repositoryUrl, -5) === ".json") {
@stof

stof Feb 19, 2012

Contributor

it should be elseif without space

Contributor

henrikbjorn commented Feb 21, 2012

symfony-standard could then debut on packagist and the install would be php composer.phar install-project symfony/standard project sounds awesome in theory.

Contributor

beberlei commented Feb 21, 2012

correct

@Seldaek Seldaek and 2 others commented on an outdated diff Feb 24, 2012

src/Composer/Command/CreateProjectCommand.php
+ if (!$package) {
+ throw new \InvalidArgumentException("Could not find package $packageName with version $version.");
+ }
+
+ if (null === $directory) {
+ $parts = explode("/", $packageName);
+ $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
+ }
+
+ $projectInstaller = new ProjectInstaller($directory, $dm);
+ $projectInstaller->install($package);
+
+ $io->write('Created new project directory for ' . $package->getName(), true);
+ $io->write('Next steps:', true);
+ $io->write('1. cd ' . $directory, true);
+ $io->write('2. composer install', true);
@Seldaek

Seldaek Feb 24, 2012

Owner

Why not do that automatically?

chdir() + the install command should do.

@beberlei

beberlei Feb 25, 2012

Contributor

if thats desired i can extend it. I prefer the two-step approach, its more explicit and this command is not the daily use-command anyways.

@Seldaek

Seldaek Feb 26, 2012

Owner

Fair enough, I just thought it would be kind of cool if you can really sum down the whole install process to a one liner. Maybe do it with a --install switch?

@till

till Mar 8, 2012

Contributor

Why not use something like --force? Or make a general switch with --yes? It could answer for ppl and get stuff done.

Kind of like apt does it when you do apt-get -y install foo.

@Seldaek

Seldaek Mar 8, 2012

Owner

These are outdated comments, the code is gone. It now installs dependencies by default, and there is currently no option to prevent that, but if someone has a good reason I guess we can add a --no-install

Seldaek merged commit 36ccd38 into composer:master Mar 8, 2012

Owner

Seldaek commented Mar 8, 2012

Merged thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment