Skip to content

Commit

Permalink
feat: allow projects to be created with any Laravel version
Browse files Browse the repository at this point in the history
  • Loading branch information
mauri870 committed Mar 9, 2022
1 parent a29b28f commit 50c9fa2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 62 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.6.0 (2022-03-09)

Features:

- Allow installation of any Laravel version supported by composer, without restrictions.
## 1.5.0 (2017-10-11)

Features:
Expand Down
32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Laravel Installer
[![Build Status](https://travis-ci.org/artesaos/laravel-installer.svg?branch=master)](https://travis-ci.org/artesaos/laravel-installer) [![Latest Stable Version](https://poser.pugx.org/artesaos/laravel-installer/v/stable)](https://packagist.org/packages/artesaos/laravel-installer) [![Total Downloads](https://poser.pugx.org/artesaos/laravel-installer/downloads)](https://packagist.org/packages/artesaos/artesaos/laravel-installer) [![Latest Unstable Version](https://poser.pugx.org/artesaos/laravel-installer/v/unstable)](https://packagist.org/packages/artesaos/laravel-installer) [![License](https://poser.pugx.org/artesaos/laravel-installer/license)](https://packagist.org/packages/artesaos/laravel-installer)

This laravel installer is an alternative like a symfony installer, where you could choose a specific version to install.
This laravel installer is an alternative to the Laravel installer and much like the Symfony installer lets you choose a specific version to install.

> Remember to remove your old laravel installer for prevent conflicts
> Remember to remove your old laravel installer to prevent conflicts
```bash
composer g remove laravel/installer
```
Expand All @@ -16,34 +16,26 @@ composer g require artesaos/laravel-installer

#### Usage

This installer works like a default laravel installer. The difference is you can choose your version.
This installer works like the default laravel installer. The difference is you can choose the Laravel Version version.
```
laravel new name version
```

The option `--interactive` is available. It will ask for packages to require on your project

Replace `name` for your project name and `version` for one of the available versions:
Replace `name` for your project name and `version` with a valid laravel version, in any format supported by composer.

`4.2`
Some examples:

`5.0`

`5.1`

`5.2`

`5.3`

`5.4`

`5.5` - Default version - You can use `LTS` instead

`master` - Install from the current master branch

`develop` - Install the development version from the next release
```bash
laravel new blog 9.3.1
laravel new blog ~5.5.0
laravel new blog ^7.1
laravel new blog master
```

You can use the help command for instructions:

```
laravel help new
```
Expand Down
53 changes: 11 additions & 42 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,9 @@ protected function configure()
The option <info>--interactive</info> is available. It will ask for packages to require on your project
Example:
<info>laravel new <comment>blog</comment> <comment>lts</comment></info>
You can choose one of this versions to install:
<comment>4.2</comment>
<comment>5.0</comment>
<comment>5.1</comment> - <info>You can use <comment>lts</comment> instead</info>
<comment>5.2</comment>
<comment>5.3</comment>
<comment>5.4</comment> - <info>Default version</info>
<comment>master</comment> - <info>Install from the current master branch</info>
<comment>develop</comment> - <info>Install the development version from the next release</info>
For example, to create a project with the latest version of laravel 8 you can run:
<info>laravel new <comment>blog</comment> <comment>^8.0</comment></info>
EOT
);
}
Expand All @@ -72,7 +62,11 @@ protected function execute(InputInterface $input, OutputInterface $output)

$version = $this->getVersion($input);

$output->writeln('<info>Set version <comment>' . $version . '</comment>...</info>');
if ($version === '') {
$output->writeln('<info>Using latest version available...</info>');
} else {
$output->writeln('<info>Using version <comment>' . $version . '</comment>...</info>');
}

$output->writeln('<info>Crafting application...</info>');

Expand Down Expand Up @@ -154,37 +148,16 @@ protected function getInstallationCommand($version, $directory)
$command = $composer . " create-project laravel/laravel --prefer-dist " . $directory;

switch ($version) {
case "4.2":
return $command . " 4.2";
break;
case "5.0":
return $command . " \"~5.0.0\"";
break;
case "5.1":
case "lts":
return $command . " \"5.1.*\"";
break;
case "5.2":
return $command . " \"5.2.*\"";
break;
case "5.3":
return $command . " \"5.3.*\"";
break;
case "5.4":
return $command . " \"5.4.*\"";
break;
case "5.5":
return $command;
break;
case "develop":
return $command . " --stability=dev \"dev-develop\"";
break;
case "master":
return $command . " --stability=dev \"dev-master\"";
break;
default:
return $command . " " . $version;
break;
}

throw new RuntimeException("The version " . $version . " doesn't exist!");
}

/**
Expand Down Expand Up @@ -221,10 +194,6 @@ protected function getVersion($input)
{
$version = $input->getArgument('version');

if ($version == "") {
$version = "5.5";
}

return strtolower($version);
}

Expand Down

0 comments on commit 50c9fa2

Please sign in to comment.