Vishal Patel
Vishal Patel

Reputation: 1745

Error in Laravel 5: Fatal error: require(): after recent Composer update

I am working on a Laravel project and it's working fine. But Recently I have updated Composer by composer update and Composer updated successfully.

Then I have removed unnecessary packges from the vendor folder. I have also removed paragonie folder from vendor, which is unwanted for me. This gave me following error.

Fatal error: require(): Failed opening required '/var/www/laravel/vendor/paragonie/random_compat/lib/random.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/laravel/vendor/composer/autoload_real.php on line 54`

I have added this folder and working fine. Any one can help me to figure out what is purpose of paragonie folder. Why it is included?

Upvotes: 0

Views: 1480

Answers (3)

nu_pagadi
nu_pagadi

Reputation: 53

Resolving this problem folowing these steps:

  1. go to your project from terminal (CLI)

  2. cd vendor

  3. svn add paragonie

  4. svn commit -m ""

And if another file is missing do the same thing. For me it works 100%. Good luck.

Upvotes: 0

MrMesees
MrMesees

Reputation: 1603

Don't manually edit composer.json, or the file-structure of the vendors folder. The vendors folder contains the dependencies and their dependencies.

The most important part about this is that you should not EVER edit a project dependency within a project. The second you do, you have broken future updates, This is a terrible thing.

If you feel this is not possible because a library needs changes, I'd suggest taking a breath.

Most libraries have some built-in configuration options, or methods of modifying the library. If they don't then maybe contribute some, or fork the library.

You can absolutely make changes to any library that has a permissive license towards source code modifications, that is why open-source code exists, but you need to do this in the right way.

You can possibly improve the code by forking using source control, which will also allow you to submit a pull-request(PR) to the package maintainers.

The benefit of trying this is that IF the package maintainers decide to accept your changes, you will be up-to-date with all of their future updates, even if you do not have time to maintain your changes, someone will probably pick them up and make their changes.

IF your PR is not accepted; I would strongly consider revisiting your initial assumptions so that you can be sure the decisions you are making are the only way, or the most beneficial way forward. Either way; it won't matter, as you can keep your fork as the version you pull from in future and either add it to packagist (only if you are really more people will benefit from it); or telling composer to pull directly from your repository (it does have to be on the internet AFAIK).

If you have to fork, you will need to ensure you can maintain the dependency, and this is accepted within your organisation. If it's you then in future, you can manually update from time-to-time from the original source library; to ensure you still enjoy the benefits of the core library, whilst keeping your changes.

THIS IS THE DIFFERENCE BETWEEN HIGH-SCHOOL CODING AND PROFESSIONAL DEVELOPMENT.

sorry for shouting / exclaiming, but this needs to be put out there more, possibly in 100ft letters somewhere.

Upvotes: 2

Pᴇʜ
Pᴇʜ

Reputation: 57683

Composer manages every package inside the vendor/ folder. You simply can't remove any folder from vendor/ without breaking something. Don't do this!

If you want to remove packages from your project then edit your composer.json and perform a composer install.

There might be some packages in your vendor folder that are not required from your composer.json. This is because ever package can have it's own requirements. If you delete one of these required packages you break it.

There is generally NO necessity to remove anything from vendor!

Note: composer update does NOT update Composer itself. It updates every package of your project! To update Composer itself use composer self-update.

I really recommend you to read the composer docs or some tutorial on how composer works for a better understanding of composer.

Upvotes: 3

Related Questions