I'm following this README and am curious if it's possible to get the following to work:
$capsule = new Illuminate\Database\Capsule\Manager;
$capsule->addConnection([
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => 'password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
# can Facades be used like this somehow?
var_dump(DB::connection()->getPdo());
var_dump(Hash::make('hash'));
I get the following error which is expected because the scripts not loading any Facades but I'm not sure how to tweak things to work:
Fatal error: Uncaught Error: Class 'DB' not found
I've also tried out the accepted answer here but still no luck (not even sure I'm using it correctly?)..
$container = new Illuminate\Container\Container();
Illuminate\Support\Facades\Facade::setFacadeApplication($container);
$container->singleton('db', 'Illuminate\Support\Facades\DB');
class_alias('Illuminate\Support\Facades\DB', 'DB');
Which gives me the following error:
Fatal error: Uncaught Error: Call to undefined method Illuminate\Support\Facades\DB::connection()
Any suggestions? Or is it just that Facades cannot be used with Illuminate Database standalone?
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2EQ36CF
via IFTTT
Aucun commentaire:
Enregistrer un commentaire