我使用Apache服务器文档根目录中的PHP文件(index.php)中的require()。 PHP文件执行失败。 apache的error_log中引发的错误如下
PHP致命错误:require():必须打开失败'/root/new/test/public/../vendor/autoload.php'(include_path ='。:/ usr / share / pear:/ usr / share / php')在/root/new/test/public/index.php,第24行
第24行有
需要DIR。'/ .. / vendor / autoload.php';
我已授予vendor目录甚至/ root / new / test文件夹的777权限。但是问题仍然存在。
httpd.conf中的apache设置如下
<VirtualHost *:80>
DocumentRoot /root/new/test/public
<Directory "/root/new/test/public">
Options +Indexes +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from All
Require local
</Directory>
</VirtualHost>
我在这里想念什么?
UPDATE 1:
我运行了composer install
,它给出了以下输出
[root@localhost test]# composer install
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
我认为您没有安装作曲家
composer install
在安装Composer后授予公用文件夹和存储的权限
您可以从composer.json自动加载文件:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Helpers/global.php",
]
},
这里我的应用程序将加载/app/Helpers/global.php,它将在全球范围内可用。它可能需要composer dumpautoload
。