[已解决]Thinkphp Error: Failed to open stream: No such file or directory vendor/autoload.php

When you first try to run thinkphp, you might get the following error.

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

Fatal error: require(): Failed opening required '/var/www/html/tp/public/../vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/tp/public/index.php on line 15

Problem Scenario: 

This problem usually happens when you download it from github (download) or clone (clone) thinkphp, we will get thinkphp into the web server, then to access it through a browser (http: // localhost / tp5 / public) .

the reason:

Although you have downloaded Thinkphp framework code and put him on your web server, but there is still a lack of dependence. In order to make Thinkphp normal operation, you should install the missing dependencies.

solve:

To resolve this error, you need to use the composer to install the missing dependencies. Composer PHP is a dependency package management tool. If your system has not been installed composer, you need to install it the first time. You can go to the official website to download Composer: https://getcomposer.org .

If you are a Linux system, you can go through the terminal installation

sudo apt install composer

Once the composer installed on your system, then you need to follow the steps below to install the missing dependencies:

- Open the terminal or command prompt

- into your catalog Thinkphp

- For example, by default, Ubuntu Linux's web root is / var / www // html; in Windos, if you put wamp installed in the D drive, then your web root will be D: / wamp / www

- assuming that you downloaded, copied Thinkphp files to a directory named tp

- Then, in the web server under Linux, you tp directory will be / var / www / html / tp

- You can enter the tp directory with the following command in the terminal: cd / var / the WWW / HTML / tp

- Run the following command

composer install

- This will depend on the installation required to run Thinkphp. Install all dependencies may take some time.

Now you should be able to properly access Thinkphp, and will not have any errors.

http://localhost/tp/public

If you have already run composer install command but still get the error, then you should run the following command:

composer update

 

Or, the best way to create and install thinkphp thinkphp project is directly composer. You can run the following command line terminal or prompt the composer command:

- Go to your web server root (is / var / www / html in Linux)

- Run the following command in a terminal:

composer create-project topthink/think name-of-your-project

- This will create a name-of-your-project directory and install Thinkphp files in the directory.

- It will also install all necessary dependencies to run Thinkphp

- Then, you can enter in your browser: htpp: // localhost / name-of-your-Project / public to visit Thinkphp

Hope this helps. Thanks.

 

Reference, translated from:  https://blog.chapagain.com.np/solved-laravel-error-failed-to-open-stream-no-such-file-or-directory-bootstrapautoload-php/

Guess you like

Origin www.cnblogs.com/wgxi/p/11746359.html