I have a parse error using eloquent with slim3












-1















I'm following the codecourse video series Authentication with Slim 3, which is about 3 years old.
I've hit a snag when it comes to using eloquent to access a mysql database.
(the relevant video: https://www.youtube.com/watch?v=70IkLMkPyPs )



the code wasn't quite the same as that currently recommended on the instructions on illuminate/database's docs, so I've modified the code slightly to follow that standard, but regardless of whether I follow Alex's code oon the vid or the following, a parse error results.



$app = new SlimApp([
'settings' => [
'displayErrorDetails' => true,

'db' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'opium3',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
]

],

]);


$container = $app->getContainer();

/*set up eloquent to use outside laravel*/
use IlluminateDatabaseCapsuleManager as Capsule;
$capsule = new Capsule;
$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();


Running the app produced this error:




Parse error: syntax error, unexpected '=' in /var/www/public/opium3/vendor/illuminate/database/DatabaseManager.php on line 65




I'm running this locally on a scotchbox vagrant set up, if that's relevant.
There's a similar question at
Parse error when run illuminate/database/capsule with bootEloquent() in PHP



but this answer doesn't resolve my issue, since the server is running php7.
I have also tried installing packages recommended by illuminate/database, installing php-mbstring, and editing the php.ini file, on the server, but the error persists.



Am I missing something obvious?










share|improve this question























  • I see the question has been downvoted. Any tips as to how it could be improved?

    – user86006
    Jan 20 at 18:03
















-1















I'm following the codecourse video series Authentication with Slim 3, which is about 3 years old.
I've hit a snag when it comes to using eloquent to access a mysql database.
(the relevant video: https://www.youtube.com/watch?v=70IkLMkPyPs )



the code wasn't quite the same as that currently recommended on the instructions on illuminate/database's docs, so I've modified the code slightly to follow that standard, but regardless of whether I follow Alex's code oon the vid or the following, a parse error results.



$app = new SlimApp([
'settings' => [
'displayErrorDetails' => true,

'db' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'opium3',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
]

],

]);


$container = $app->getContainer();

/*set up eloquent to use outside laravel*/
use IlluminateDatabaseCapsuleManager as Capsule;
$capsule = new Capsule;
$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();


Running the app produced this error:




Parse error: syntax error, unexpected '=' in /var/www/public/opium3/vendor/illuminate/database/DatabaseManager.php on line 65




I'm running this locally on a scotchbox vagrant set up, if that's relevant.
There's a similar question at
Parse error when run illuminate/database/capsule with bootEloquent() in PHP



but this answer doesn't resolve my issue, since the server is running php7.
I have also tried installing packages recommended by illuminate/database, installing php-mbstring, and editing the php.ini file, on the server, but the error persists.



Am I missing something obvious?










share|improve this question























  • I see the question has been downvoted. Any tips as to how it could be improved?

    – user86006
    Jan 20 at 18:03














-1












-1








-1








I'm following the codecourse video series Authentication with Slim 3, which is about 3 years old.
I've hit a snag when it comes to using eloquent to access a mysql database.
(the relevant video: https://www.youtube.com/watch?v=70IkLMkPyPs )



the code wasn't quite the same as that currently recommended on the instructions on illuminate/database's docs, so I've modified the code slightly to follow that standard, but regardless of whether I follow Alex's code oon the vid or the following, a parse error results.



$app = new SlimApp([
'settings' => [
'displayErrorDetails' => true,

'db' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'opium3',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
]

],

]);


$container = $app->getContainer();

/*set up eloquent to use outside laravel*/
use IlluminateDatabaseCapsuleManager as Capsule;
$capsule = new Capsule;
$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();


Running the app produced this error:




Parse error: syntax error, unexpected '=' in /var/www/public/opium3/vendor/illuminate/database/DatabaseManager.php on line 65




I'm running this locally on a scotchbox vagrant set up, if that's relevant.
There's a similar question at
Parse error when run illuminate/database/capsule with bootEloquent() in PHP



but this answer doesn't resolve my issue, since the server is running php7.
I have also tried installing packages recommended by illuminate/database, installing php-mbstring, and editing the php.ini file, on the server, but the error persists.



Am I missing something obvious?










share|improve this question














I'm following the codecourse video series Authentication with Slim 3, which is about 3 years old.
I've hit a snag when it comes to using eloquent to access a mysql database.
(the relevant video: https://www.youtube.com/watch?v=70IkLMkPyPs )



the code wasn't quite the same as that currently recommended on the instructions on illuminate/database's docs, so I've modified the code slightly to follow that standard, but regardless of whether I follow Alex's code oon the vid or the following, a parse error results.



$app = new SlimApp([
'settings' => [
'displayErrorDetails' => true,

'db' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'opium3',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
]

],

]);


$container = $app->getContainer();

/*set up eloquent to use outside laravel*/
use IlluminateDatabaseCapsuleManager as Capsule;
$capsule = new Capsule;
$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();


Running the app produced this error:




Parse error: syntax error, unexpected '=' in /var/www/public/opium3/vendor/illuminate/database/DatabaseManager.php on line 65




I'm running this locally on a scotchbox vagrant set up, if that's relevant.
There's a similar question at
Parse error when run illuminate/database/capsule with bootEloquent() in PHP



but this answer doesn't resolve my issue, since the server is running php7.
I have also tried installing packages recommended by illuminate/database, installing php-mbstring, and editing the php.ini file, on the server, but the error persists.



Am I missing something obvious?







php






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 20 at 15:10









user86006user86006

31




31













  • I see the question has been downvoted. Any tips as to how it could be improved?

    – user86006
    Jan 20 at 18:03



















  • I see the question has been downvoted. Any tips as to how it could be improved?

    – user86006
    Jan 20 at 18:03

















I see the question has been downvoted. Any tips as to how it could be improved?

– user86006
Jan 20 at 18:03





I see the question has been downvoted. Any tips as to how it could be improved?

– user86006
Jan 20 at 18:03












1 Answer
1






active

oldest

votes


















2














Make sure you're using at least PHP 7.1.



/illuminate/database/DatabaseManager.php is using a short hand version of the list()-construct which wasn't available until PHP 7.1.



The "old" way is to:



list($var1, $var2) = someFunciton(); 


while you, since PHP 7.1, can also do:



[$var1, $var2] = someFunction();


The row the error is thrown in is this:



[$database, $type] = $this->parseConnectionName($name);


Note:



If you can't upgrade your PHP version from 7.0 to 7.1.3+, you need to use an older version of the Illuminate/Database-package. Use version 5.5 for PHP 7.0 and then 5.6+ on PHP 7.1.3+






share|improve this answer


























  • thankyou, that was helpful & informative

    – user86006
    Jan 20 at 18:02













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54277810%2fi-have-a-parse-error-using-eloquent-with-slim3%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Make sure you're using at least PHP 7.1.



/illuminate/database/DatabaseManager.php is using a short hand version of the list()-construct which wasn't available until PHP 7.1.



The "old" way is to:



list($var1, $var2) = someFunciton(); 


while you, since PHP 7.1, can also do:



[$var1, $var2] = someFunction();


The row the error is thrown in is this:



[$database, $type] = $this->parseConnectionName($name);


Note:



If you can't upgrade your PHP version from 7.0 to 7.1.3+, you need to use an older version of the Illuminate/Database-package. Use version 5.5 for PHP 7.0 and then 5.6+ on PHP 7.1.3+






share|improve this answer


























  • thankyou, that was helpful & informative

    – user86006
    Jan 20 at 18:02


















2














Make sure you're using at least PHP 7.1.



/illuminate/database/DatabaseManager.php is using a short hand version of the list()-construct which wasn't available until PHP 7.1.



The "old" way is to:



list($var1, $var2) = someFunciton(); 


while you, since PHP 7.1, can also do:



[$var1, $var2] = someFunction();


The row the error is thrown in is this:



[$database, $type] = $this->parseConnectionName($name);


Note:



If you can't upgrade your PHP version from 7.0 to 7.1.3+, you need to use an older version of the Illuminate/Database-package. Use version 5.5 for PHP 7.0 and then 5.6+ on PHP 7.1.3+






share|improve this answer


























  • thankyou, that was helpful & informative

    – user86006
    Jan 20 at 18:02
















2












2








2







Make sure you're using at least PHP 7.1.



/illuminate/database/DatabaseManager.php is using a short hand version of the list()-construct which wasn't available until PHP 7.1.



The "old" way is to:



list($var1, $var2) = someFunciton(); 


while you, since PHP 7.1, can also do:



[$var1, $var2] = someFunction();


The row the error is thrown in is this:



[$database, $type] = $this->parseConnectionName($name);


Note:



If you can't upgrade your PHP version from 7.0 to 7.1.3+, you need to use an older version of the Illuminate/Database-package. Use version 5.5 for PHP 7.0 and then 5.6+ on PHP 7.1.3+






share|improve this answer















Make sure you're using at least PHP 7.1.



/illuminate/database/DatabaseManager.php is using a short hand version of the list()-construct which wasn't available until PHP 7.1.



The "old" way is to:



list($var1, $var2) = someFunciton(); 


while you, since PHP 7.1, can also do:



[$var1, $var2] = someFunction();


The row the error is thrown in is this:



[$database, $type] = $this->parseConnectionName($name);


Note:



If you can't upgrade your PHP version from 7.0 to 7.1.3+, you need to use an older version of the Illuminate/Database-package. Use version 5.5 for PHP 7.0 and then 5.6+ on PHP 7.1.3+







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 20 at 15:41

























answered Jan 20 at 15:34









Magnus ErikssonMagnus Eriksson

7,21641327




7,21641327













  • thankyou, that was helpful & informative

    – user86006
    Jan 20 at 18:02





















  • thankyou, that was helpful & informative

    – user86006
    Jan 20 at 18:02



















thankyou, that was helpful & informative

– user86006
Jan 20 at 18:02







thankyou, that was helpful & informative

– user86006
Jan 20 at 18:02






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54277810%2fi-have-a-parse-error-using-eloquent-with-slim3%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Liquibase includeAll doesn't find base path

How to use setInterval in EJS file?

Petrus Granier-Deferre