Yii2.0.9 - Vendor folder doen't push on github repo.

Hello there,

I have build web app in Yii-2.0.9 and its working very well in local and live. but i want to upload whole code in github repository. all folders/files upload successfully except the vendor folder. i tried many to upload “Vendor” folder on github repository. but i didn’t get success on it.

So, have you any idea about that? why is not uploading "Vendor" folder on github repository?

Please help me on this

Thanks

Hi,

The VENDOR directory is automatically downloaded and updated according to the requisitisos the composer file.

Thanks for reply,

Okay, but VENDOR dir is not automatically download in github repo… and getting below errors on site causing missing VENDOR dir.

Warning: require(/var/www/html/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 7

Fatal error: require(): Failed opening required ‘/var/www/html/vendor/autoload.php’ (include_path=’.:/usr/local/lib/php’) in /var/www/html/index.php on line [b]7

[/b]Is ther any command to put verndor dir in github repo?[b]

[/b]Thanks[b]

[/b]

try:


composer update

I already tried that via command prompt in my local repo, but its created vendor folder in local repo. but while pushing all code in repo at that time vendor folder doesn’t push on repo.

Could you please tell me, what i missed?

Thanks

I don’t know why you should be pushing the vendor folder to GitHub! You can always have the latest downloaded for you using composer.

However, if you insist, there is a file called .gitignore in the project root. Open that file and comment out the line that has


'/vendor'

Now since you have already committed and the .gitignore was cached, you want to clear the cache and load the new .gitignore. First commit all unsaved changes and then run


git rm -r --cached

to load the new file. After that you should be able to commit your vendor files to Github

Thanks a lot

You really don’t want to upload the vendor folder to Github.

It takes ages, and is completely pointless. :)

Why do you want to do that?

The vendor folder is in the gitignore for a very good reason: the folder is generated by running Composer.

Do you want to upload the assets and the runtime directories too? No, of course not.

Why do you need/want to add the vendor directory?

To illustrate:

I just cloned my project which has 194 files and 67 subfolders and a weight of 2.5MB.

After running composer, bower and npm, the size has grown to 239.4MB, with 16779 files in 3519 subfolders…

Generated ‘things’ should never be committed to source control. :)

Just answering more in detail.

The ‘Vendor’ folder consist of 3rd party code put into components. So instead of putting these code in your project you can simply add them to your json file. Think of it as a list of plugins. The reason is that it’s just duplicated.


composer update

Once you download the git file, you can run composer update. This tells composers to go get the required plugins by downloading from the list, most likely also on github. It keeps your git filled with only the essential code that is not available elsewhere.

General rule of thumb: Don’t commit generated content (i.e. vendor files, runtime, web/assets etc.).

By default, the Yii2 templates like basic and advanced usually have .gitignore for the above-mentioned files by default.