0

I have 2 PHP versions on my PC. In the past I was using PHP 8 (8.1.13) like this to install laravel:

C:\PHP8\php8.exe C:\composer\composer.phar create-project laravel/laravel Project-Name

It was working for 2 projects, which I installed a few months ago. Today I try to create a new laravel project, but it tells me I need to upgrade my composer:

Problem 1
    - laravel/framework[v10.0.0, ..., v10.3.1] require composer-runtime-api ^2.2 -> found composer-runtime-api[2.0.0] but it does not match the constraint.
    - Root composer.json requires laravel/framework ^10.0 -> satisfiable by laravel/framework[v10.0.0, ..., v10.3.1].

The most recent version for laravel is now 10 and it seems it needs a higher version of composer. Now I dont want to upgrade composer itself because I am not sure how this will affect the other projects, or is it safe to do so?

My solution was to install the same laravel version, which I used in the other projects, so I did this:

C:\PHP8\php8.exe C:\composer\composer.phar create-project --prefer-dist laravel/laravel:^7.29 Project-Name

This for some reason gives me this error:

package:discover --ansi handling the post-autoload-dump event returned with error code 255

I tried now all solutions, which I found online, but nothing works, any idea?

UPDATE:

Setting up now everything fresh in a venv via phpStorm. I use now the newest version of composer and my PHP8 installation. This leads to the same error:

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
Roman
  • 3,563
  • 5
  • 48
  • 104
  • Take a look at these answers https://stackoverflow.com/questions/50840960/script-php-artisan-packagediscover-handling-the-post-autoload-dump-event-retur – Aless55 Mar 08 '23 at 15:45
  • 1
    Maybe off-topic, but when you are using different PHP versions you should start to use docker. https://www.docker.com/ – Foobar Mar 08 '23 at 15:47
  • @Aless55 I was this already, I cannot even create the laravel project and I am on windows – Roman Mar 08 '23 at 15:53
  • @Foobar I do not understand how exactly docker helps here. I first need to generate the source files on my machine before I can write a Dockerfile and the docker-compose.yml, but generating the source files does not work for me. – Roman Mar 08 '23 at 16:07
  • You could also setup different windows machines with docker not only laravel projects. – Aless55 Mar 08 '23 at 16:11
  • 2
    I would simply try and upgrade composer, I am not sure why the old versions should break, if they do, you can simply reinstall an older composer version or even better, upgrade the old projects – Aless55 Mar 08 '23 at 16:14
  • @Aless55 I did not know this, will research on how to do it. Thanks – Roman Mar 08 '23 at 16:14
  • 1
    `sudo composer self-update` – matiaslauriti Mar 08 '23 at 18:36

0 Answers0