A
A
Alexey2018-05-06 01:39:05
PHP
Alexey, 2018-05-06 01:39:05

How to install Eloquent?

Help me install and attach Eloquent ORM to your project outside of Laravel (Yes, it is outside of Laravel)
I don’t really understand composer, and there is no installation code in the github repository , in short - a problem :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2018-05-06
@ichubinets

there is no code to install, in short - a problem :(

composer require illuminate/database
Well, the config is in the readme
use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

$capsule->addConnection([
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'database',
    'username'  => 'root',
    'password'  => 'password',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
]);

// Set the event dispatcher used by Eloquent models... (optional)
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$capsule->setEventDispatcher(new Dispatcher(new Container));

// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();

// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$capsule->bootEloquent();

well, of course, do not forget to connect the composer first
require 'vendor/autoload.php';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question