2
votes

Im follow phpacademys new authentication tutorial https://www.youtube.com/watch?v=PF2WkRCZfBg

i have a class file database.php:

<?php
use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

$capsule->addConnection([
 'driver'     => $app->config->get('db.driver'),
 'host'       => $app->config->get('db.host'),
 'database'   => $app->config->get('db.name'),
 'username'   => $app->config->get('db.username'),
 'password'   => $app->config->get('db.password'),
 'charset'    => $app->config->get('db.charset'),
 'collation'  => $app->config->get('db.collation'),
 'prefix'     => $app->config->get('db.prefix')
]);

$capsule->bootEloquent();

however it throws up this error:

Fatal error: Class 'Illuminate\Database\Capsule\Manager' not found in C:\xampp\htdocs\boilerplate\app\database.php on line 4

i have required it in start.php

<?php
require 'database.php';
//############ NAMESPACING ################//
use Slim\Slim; //import slim
use Noodlehaus\Config;
use Boilerplate\User\User;
//#########################################//

session_cache_limiter(false);
session_start();

ini_set('display_errors','on'); //TURN OFF ON LIVE SITE

define('INC_ROOT', dirname(__DIR__)); //create local root

require INC_ROOT . '/vendor/autoload.php'; // autoload in all the      dependencies in the vendor files.

$app = new Slim([
'mode' => file_get_contents(INC_ROOT . '/mode.php')
]); //assign the entire app file to a variable

$app->configureMode($app->config('mode'), function() use ($app){
$app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php"); //pull in the config file
});

$app->container->set('user', function(){
    return new User;
});
2
Are you pulling in Illuminate\Database using composer ?nathanmac
yes i am this is my json file { "autoload": { "psr-4" : { "Boilerplate\\" : "app/Boilerplate" } }, "require": { "slim/slim": "~2.0", "slim/views": "0.1.*", "phpmailer/phpmailer": "~5.2", "hassankhan/config": "0.8.*", "twig/twig": "~1.0", "illuminate/database": "~5.0", "ircmaxell/random-lib": "~1.1" }tom Bannister

2 Answers

2
votes

Make sure you've added Illuminate\Database to you're composer file and run composer update

Then put require 'database.php'; after you're adding the autoloader

require INC_ROOT . '/vendor/autoload.php';

// Below here
0
votes

I had the same error. In my case the solution was to install composer again with the next command:

composer install

If you are using docker, make sure that you are inside the container before run the install command.

docker-compose run <app_name> bash