0

I created a Helpers.php file in order to seperate some logic between my API and Web, everything seems to run fine on my local host using WAMP but when I am trying to seed the database on the ubuntu server I am getting the following error.

App\Providers\HelperServiceProvider::register(): Failed opening required '/var/www/html/dev/lci-system-status/app\helpers.php' (include_path='.:/usr/share/php')

My first instinct tells me that the \ the wrong way is the reasoning behind this so I went to my composer.json and it shows the correct way under the autoload

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

I cant seem to figure out why this is backwards, can someone point me in the right direction on solving this?

Striker
  • 626
  • 1
  • 7
  • 24

1 Answers1

1

It looks like your JSON is fine. Make sure that you are using the full path to your file. Accessing the file on WAMP will be different since you are navigating a file system path whereas for the real version, you need to include the virtual filepath. For your case, include the document root. Take a look at this similar issue and it's answer for a more specific explanation.

"If you change your code to something like

require_once $_SERVER['DOCUMENT_ROOT'].'/var/www/html/dev/lci-system-status/app\helpers.php';

It will work from any place in the file directory."

Rook
  • 141
  • 13
  • Can you elaborate on it can work any place in the directory? Are we talking about the entire projects directory? – Striker Jul 24 '18 at 18:58
  • @Striker Yes we are talking about the entire projects directory. By adding that line of code, no matter where you are in your server directory, you can access that desired file. My point originally is that you need to make sure that, on your actual server, you are using the full path to that file starting at the document root. – Rook Jul 24 '18 at 19:08
  • Added it to the providers and it ended up working! Thank you for your help! – Striker Jul 24 '18 at 19:33