5

I have a server that is still running PHP 7.4.x

I, therefore, need to install laravel 8.x (the current version of laravel is 9.x) with laravel-sail. Since I don't have PHP running on the laptop I am using for development, I cannot install laravel with composer.

When I run the install command curl -s "https://laravel.build/example-app?with=mysql" | bash then laravel 9.x is installed.

How can I make laravel-sail install laravel 8.x?

cw24
  • 1,613
  • 2
  • 22
  • 31
  • funnily enough if you do `curl -s "https://laravel.build/example-app?with=mysql&php=74" | bash` it should install a container with PHP 7.4 and Laravel 9 – apokryfos Apr 20 '22 at 17:50

2 Answers2

1

you can download Laravel 8 or other versions from laravel github repository and replace it with your local project on sail

be careful laravel Sail and related parts (docker-compose,...) should not be deleted

the second way is that clone laravel 8 from github repo and install sail into this project

https://laravel.com/docs/8.x/sail#installing-sail-into-existing-applications

laravel 8.6.12 github repo: enter link description here

Keyvan Gholami
  • 168
  • 1
  • 3
  • 15
  • Thanks for the answer, but this doesn't quite solve the problem. I don't have PHP installed on my laptop at all, and without PHP, I cannot use composer to install sail into the project. I am looking for a way to use the 'curl' command to install an older version of laravel. Once I have the docker environment up and running, I will use its PHP. – cw24 Apr 21 '22 at 13:17
  • With the first way I told you, you do not need to have PHP or any other tool installed on your laptop. – Keyvan Gholami Apr 21 '22 at 13:20
  • Yes, thanks. You're right, that will work without PHP. I overlooked that part of your answer. In the meantime, though, I have found a way that seems even more convenient. – cw24 Apr 21 '22 at 14:16
  • You are right, but the service provider must allow you to choose the version, which is currently not possible in the way you want. I had this problem too, but for now the best possible way was what I said. – Keyvan Gholami Apr 21 '22 at 17:35
0

apokryfos's comment got me thinking and I tried the following curl command

curl -s "https://laravel.build/example-app?with=mysql&php=74" | bash

That worked. My composer.json looks like this

"require": {
    "php": "^7.3|^8.0",
    "fruitcake/laravel-cors": "^2.0",
    "guzzlehttp/guzzle": "^7.0.1",
    "laravel/framework": "^8.75",
    "laravel/sanctum": "^2.11",
    "laravel/tinker": "^2.5"
},

... and with sail up, I have a Laravel v8.83.9 up and running.

For some reason, the PHP version is still 8.1, but I can change the PHP version in the docker-compose.yml to PHP 7.4 and rebuild. With that, I have (PHP v7.4.28).

Update: I originally thought adding a "laravel=8" to the curl command would load laravel in version 8.x, but this had no effect. Adding php=74 is enough to get laravel in version 8.x, but it does not set PHP to version 7.4. That needs to be done in the docker-compose.yml file.

cw24
  • 1,613
  • 2
  • 22
  • 31