I tried creating larvel 9 project using composer. Since my machine don't have php 8 installed on it. While running command composer create-project laravel/laravel --prefer-dist myapp
, a laravel 8 project is created.
While running composer create-project laravel/laravel:^9.0 --prefer-dist myapp
it gives me error as
Could not find package laravel/laravel with version ^9.0 in a version installable using your PHP version, PHP extensions and Composer version.
.
So, my question is, i dont want to install php8 on my machine rather i want to create a laravel 9 project using docker but i seems to get lost on it.
I did tried creating project using following command:
composer create-project laravel/laravel=9.* --ignore-platform-req your-project-name --prefer-dist
It gives me the same error as above Could not find package laravel/laravel with version ^9.0 in a version installable using your PHP version, PHP extensions and Composer version.
You can create a docker container with PHP already installed in it and map it to your local drive:
docker run -it --rm -v $(pwd):/work -w /work php:alpine3.14
That works in bash. If you're in windows, replace the $(pwd)
bit with the directory you want to create the project in.
This should give you a shell that allows you to use php without having it on your machine. You can try your project init there and it'll create the files on your local drive. You can exit by typing ctrl+d or typing exit
.
If this image doesn't have what you want, you can try this one:
docker run -it --rm -v $(pwd):/work -w /work composer
Which already has composer installed.
For a full run, taking care of file ownership and with the correct instructions to composer, you'd want to run this:
docker run -it --rm -v $(pwd):/work -w /work -u 1000:1000 composer:latest create-project laravel/laravel=9.* --ignore-platform-reqs --no-scripts /work