How to generate composer.json from the Laravel vendor directory - laravel

Unfortunately, I deleted composer.json and composer.lock, but my vendor folder is intact and has all dependency packages installed. Is there a way to generate composer.json through the vendor folder? Any way to reverse engineer?

Related

Laravel vendor files

I am working on an application with laravel 8, whenever I run composer update 5000+ vendor files are tracked by GitHub however /vendor is added into the .gitignore file. here is a snap of my .gitignore file:
Might be possible that you have already staged/added the vendor folder before putting in the .gitignore file. Or you have manually staged/added the folder to git through command.
In any case, one solution for you is to unstage the files by using
git reset /vendor/*
and if this doesn't solve your problem, then it might be possible that you already have committed older files into git; so, /vendor files are getting tracked by git.
Solution steps:
Delete the /vendor folder.
Make a clean commit of tracked files inside /vendor (if there are any)
Run composer install again to get back /vendor folder.
After these steps, vendor will not be tracked. (Considering /vendor/ is still present in the .gitignore file)

What happens when new items are placed in composer.json file within Laravel Application

I am having a hard time thoroughly understanding how the composer.json file works within a Laravel application. I can build Laravel projects, but I am self-taught and have never fully understand what happens in the composer.json file.
For example, I have a current project that has the following within composer.json:
"require": {
"php": "^7.2",
I attempted doing composer require livewire/livewire, but then realized livewire required a newer version of php. I am using XAMPP 3.2.4 and the php version is 7.2.28. So, I backed up my files from my htdocs and database and am downloading a newer version of XAMPP.
I assume I would then change my composer.json file to:
"require": {
"php": "^7.4",
But, I cannot understand what is really happening here. Is this just saying that the server needs to have php version 7.4 or higher on it for the application to work? Or is it placing new files in the vendor directory? Do I need to delete any files out of the vendor directory?
composer is the php packages and dependency manager. to not copy past all what you need for your project you use composer.
when you write a package name in the composer.json require section then composer will fetch it from his sources (The main source of composer is packagist).
About the vendor directory, if you delete it your application will simply don't work, if you are storing the app somewhere (in a repo for example), you provide only the composer.json and then you will have the same vendor with taping 'Composer install'
Good luck

What files are need to upload after composer required <package>?

So my hosting company not support composer. and reuploading all Laravel framework php files are too much take time just for one composer package. what are files need to be uploaded to hosting after composer required?
all i know is "package" folder in vendor folder, composer.json, and "config" file in config folder. is there any other files and folder?
You must upload vendor/composer and vendor/autoload.php too..
I hope this works
The file that you forget: Facades, ServiceProvider
the easiest way is reupload all vendor directory. or track all vendor directory using git, so you can archive the different after update composer and upload it

Why is vendor package not pushing to github even when "/vendor" is not listed in .gitignore file?

When I add files to my local repository, some vendor packages are excluded even though they are not listed in the .gitignore file. Since they are not pushed to the remote repository, other developers are not able to pull the vendor packages.
The Vendors files are not to upload on github.The composer.json file of your laravel project have all the information to install all of your vendors.So try to update your composer.
To update composer use cmd or terminal command:
composer update
composer install
Be sure that the composer.json file is not ignore by .gitignore file.
Fixing the root .gitignore is not enough.
I had the same problem and found out that there are multiple .gitignore in subfolders.

A composer's package doesn't exist anymore, and I have a copy. What can I do?

Time ago, I installed a dependency on a Symfony project. It was the package mograine/calendar-bundle, but now this project doesn't exist anymore and has disappeared from github. It was a fork of another package with some modifications that I need for the project I'm working on.
Of course, I have a copy of the package (under vendor/mograine folder). But, currently I'm unable to run the composer install order, because this package doesn't exist.
And my question is: What can I do to solve this problem? Can I tell composer that this package is installed locally? If so, what should I do to install the package locally? Or I must create a github account and upload all the original files?
If its a normal symfony project, you can simply move it to your src folder resp. "copy past the namespace directories to the src directory" and remove it from the composer.json.
The src folder is autoloaded f.e.
"autoload": {
"psr-0": {
"": "src/"
}
Take care that the namespaces and pathes are correct.
Also see here: moving bundle from vendor to src directory

Resources