Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Corrupted composer.json file in Laravel 8

When I tried to remove the package maatwebsite/excel from my project, I damaged something badly. The problem is that I can't track the changes I made. Before I removed maatwebsite/excel from composer.json, I removed phpoffice/phpspreadsheet probably from composer.json. But I can't remember exactly. Because when I check out an older version with git, I can no longer find this entry. Every time I call Composer, it now gives a considerable error message that starts like the following.

In ArrayLoader.php line 44: Unknown package has no name defined ([{"name":"asm89/stack-cors","version":"v2.0.1","version_normalized":"2.0.1.0","source":{"type":"git","url":"https://github.com/asm89/stack-cors.git","reference":"23f469e81c65e2fb7fc7bce371fbdc363fe32adf"},"dist":{"type":"zip","url":"https://api.github.com/repos/asm89/stack-cors/zipball/23f469e81c65e2fb7fc7bce371fbdc363fe32adf","reference":"23f469e81c65e2fb7fc7bce371fbdc363fe32adf","shasum":">"},"require":{"php":"^7.0","symfony/http->foundation":"~2.7|~3.0|~4.0|~5.0","symfony/http-kernel":"~2.7|~3.0|~4.0|~5.0"},"require-dev":{"phpunit/phpunit":"^6|^7|^8|^9","squizlabs/php_codesniffer":"^3.5"},"time":"2020-05-31T07:17:05+00:00","type":"library","extra":{"branch-alias":{"dev-master": "2.0-dev"}},"installation-source":"dist","autoload":{"psr-4":{"Asm89\Stack\":"src/"}},"notification-url":"https://packagist.org/downloads/","license":["MIT"],"authors":[{"name":" Alexander","email":"[email protected]"}],"description":"Cross-origin resource sharing library and stack middleware","homepage":"https://github.com/asm89/stack-cors","keywords":["cors","stack"],"install-path":"../asm89/stack-cors"},{"name":"bacon/bacon-qr-code","version":"2.0.2","version_normalized":"2.0.2.0","source":{"type":"git","url":"https://github.com/Bacon/BaconQrCode.git","reference":"add6d9ff97336b62f95a3b94f75cea4e085465b2"},"dist":{"type":"zip","url":"https://api.github.com/repos/Bacon/BaconQrCode/zipball/add6d9ff97336b

The error message is 165K in size. Maybe, someone has a tip for me on how to solve this problem?

like image 318
peterw Avatar asked Dec 13 '20 09:12

peterw


1 Answers

I managed to solve this by running:

composer.json file in remove recent custom changes otherwise recent change in a check any existing syntax error

Step: 1 remove the vendor folder

rm -rf vendor/

step: 2 remove the composer.lock

rm composer.lock

step: 3 composer update command using composer generates a file called composer.lock and update a folder called vendor

composer update

step: 4 then use this command

 composer dump-autoload
like image 190
Vishal Vaghasiya Avatar answered Sep 17 '22 15:09

Vishal Vaghasiya