skip to Main Content

I use require() from a PHP file(index.php) inside Document Root of Apache server. The PHP file is failing execution. The error thrown in apache’s error_log is below

PHP Fatal error: require(): Failed opening required
‘/root/new/test/public/../vendor/autoload.php’
(include_path=’.:/usr/share/pear:/usr/share/php’) in
/root/new/test/public/index.php on line 24

The line 24 has

require DIR.’/../vendor/autoload.php’;

I have given 777 permission to vendor directory and even to the /root/new/test folder. But still the issue occurs.

The apache settings in httpd.conf is as below

<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>

What am i missing here?

UPDATE 1:

I have run composer install and it gives the below output

[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 IlluminateFoundationComposerScripts::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.

2

Answers


  1. I think you don’t install composer

    composer install
    

    After Install Composer give permission the public folder & storage

    Login or Signup to reply.
  2. You can autoload files from your composer.json:

    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\": "app/"
        },
        "files": [
            "app/Helpers/global.php",
        ]
    },
    

    Here my application will load /app/Helpers/global.php and it’ll be available globally. It may require a composer dumpautoload.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search