Laravel - $_SERVER['DOCUMENT_ROOT'] Empty When Running Queued Jobs?
In some of my files I have these sorts of lines:
Usually all is well. Now I am running some queued jobs, and I am seeing errors of the sort:
Failed opening required '/../vendor/stripe/stripe-php/init.php' (include_path='.:/usr/local/php5/lib/php') in /Library/WebServer/Documents/mysite/app/Somemodel.php:9
So it is as if when things are executing from artisan
$_SERVER['DOCUMENT_ROOT'] is empty.
I am on a MAC with Sierra. Maybe there is some setting that I overlooked?
Queued jobs are running in the background so
$_SERVER['DOCUMENT_ROOT'] is empty, because it's a path retrieved from the web server directive
It also explains why it's empty when running the Artisan CLI
You can require the file using the
require_once base_path() . '/vendor/stripe/stripe-php/init.php';
Here's the difference in Artisan Tinker
~/Sites/laravel (master ✗) ✹ ★ ᐅ tinker Psy Shell v0.9.9 (PHP 7.3.9-1~deb10u1 — cli) by Justin Hileman >>> require_once base_path() . '/vendor/stripe/stripe-php/init.php'; => true >>> require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/stripe/stripe-php/init.php'; PHP Fatal error: Failed opening required '/vendor/stripe/stripe-php/init.php' in Psy Shell code on line 1 >>> $_SERVER['DOCUMENT_ROOT'] => "" >>> base_path() => "/home/caddy/Sites/laravel"
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms