Naou Naou - 1 month ago 8
PHP Question

Troubles when updating RedBean PHP ORM to the last version using Composer

I'm new to RedBean, my application was working, but when I updated RedBean to the last version using Composer, I got this error,
Fatal error: Class 'RedBean_Facade' not found in my bootstrap.php file :

<?php
require_once __DIR__ . '/config.inc.php';
require_once __DIR__ . '/../vendor/autoload.php';

use RedBean_Facade as R;

if (empty(R::$currentDB)) {
$dsn = sprintf('%s:host=%s;dbname=%s', DB_TYPE, DB_HOST, DB_NAME);
R::setup($dsn, DB_USER, DB_PASSWORD);
}

R::close();


I don't understand if it's releated to the new version of RedBean or to my Composer autoloader which take into account just one library?

Thanks in advance for your help!

Answer
PHP Fatal error:  Class 'R' not found
PHP Fatal error:  Class 'RedBean_Facade' not found

can both be solved using this new syntax:

use RedBeanPHP\R;

I've tested it successfully in version 4.3.0

Comments