I'm using eloquent orm independently(not in laravel). In a higher level folder I tried:
include '../app/configdb.php';
Which does not work: However if I use this:
$oldcwd = getcwd();
chdir("../");
include 'app/configdb.php';
chdir($oldcwd);
This works. This is only true of my eloquent initialization file. Later in same file I:
require '../views/petlist.php';
And that works. Any ideas why the ../ won't work? And I did try require instead of include.
The configdb.php loads the eloquent orm stuff. Contents of that file. So yes from this file eloquent is requiring other stuff.
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
require_once 'vendor/autoload.php';
$capsule = new Capsule();
$capsule->addConnection([
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'pbackdate',
'username' => 'root',
'password' => 'xxxxxxxxxxxxxxxxxxxxxxxx',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
//added/
//use Illuminate\Events\Dispatcher;
//use Illuminate\Container\Container;
//$capsule->setEventDispatcher(new Dispatcher(new Container));
//added
$capsule->setAsGlobal();
$capsule->bootEloquent();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.