Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to make a mysql connection within a php environment using Slim and the package illuminate/database. Following the documentation I have created a new $capsule instance, I have passed the array with connection data through the addConnection method and then I have run bootEloquent() method:

<?php

use IlluminateDatabaseCapsuleManager as Capsule;


$capsule = new Capsule;

$capsule->addConnection([
  'driver' => $app->config->get('db.driver'),
  'host' => $app->config->get('db.host'),
  'database' => $app->config->get('db.database'),
  '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')
]);

#here the output seems correct...
#var_dump($capsule);

$capsule->bootEloquent();


 ?>

Unfortunately when I run bootEloquent() it goes through an error:

Parse error: parse error in /Sites/auth/vendor/illuminate/database/Eloquent/Model.php on line 597

The problem seems related to the Eloquent Model. I have already tried to update the composer.json file with different versions. I have also installed again each package, but the parse error still remains.

Currently the project is running on: PHP Version 5.6.30.

My current composer json file with all dependencies

{
    "autoload": {
      "psr-4": {
        "Business": "app/Business"
      }
    },
    "require": {
        "slim/slim": "~2.0",
        "slim/views": "0.1.*",
        "twig/twig": "~1.0",
        "phpmailer/phpmailer": "~5.2",
        "hassankhan/config": "0.8.*",
        "illuminate/database": "~5.0",
        "alexgarrett/violin": "2.*",
        "ircmaxell/random-lib": "~1.1"
    }
}

Can someone explain me why I'm getting this strange bad situation? Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
165 views
Welcome To Ask or Share your Answers For Others

1 Answer

Have a look at your composer.lock to see which version of illuminate/database got installed. The later ones are not compatible with PHP 5.6.30, but require PHP 7. You could try to enforce that version constraint through "illuminate/database": "~5.4.0"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...