cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.2.8 PHP Parse Error unexpected '=>" in env line 3 setup:upgrade

SOLVED

Magento 2.2.8 PHP Parse Error unexpected '=>" in env line 3 setup:upgrade

Hi,

 

I've been trying to run

bin/magento setup:upgrade

after creating a module and wanting to update the database.

 

and I get this error

PHP Parse error:  syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /var/www/html/magento/app/etc/env.php on line 3

 

Here is the env.php file code

<?php
return 1;
   'backend' => [
        'frontName' => 'Michael'
    ],
    'crypt' => [
        'key' => 'baf37aed803fb1001e493ebd6c4accbb'
    ],
    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'localhost',
                'dbname' => 'magento',
                'username' => 'root',
                'password' => 'root',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1'
            ]
        ]
    ],
    'resource' => [
        'default_setup' => [
            'connection' => 'default'
        ]
    ],
    'x-frame-options' => 'SAMEORIGIN',
    'MAGE_MODE' => 'developer',
    'session' => [
        'save' => 'files'
    ],
    'cache_types' => [
        'config' => 0,
        'layout' => 0,
        'block_html' => 0,
        'collections' => 0,
        'reflection' => 0,
        'db_ddl' => 0,
        'eav' => 0,
        'customer_notification' => 0,
        'config_integration' => 0,
        'config_integration_api' => 0,
        'full_page' => 0,
        'config_webservice' => 0,
        'translate' => 0,
        'vertex' => 0
    ],
    'install' => [
        'date' => 'Thu, 04 Apr 2019 11:03:42 +0000'
    ]
];

I'm running php 7.1.27

PHP 7.1.27-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar  7 2019 20:02:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.27-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2.2.8 PHP Parse Error unexpected '=>" in env line 3 setup:upgrade

Hello @michael_myburgh 

 

Yes there is a mistake in your code which is Return 1;

 

Because here you don't require to do Return a number, May be it is typo error or unknowingly added.

 

Here is the final code which will resolved your error.

 

<?php
return [
   'backend' => [
        'frontName' => 'Michael'
    ],
    'crypt' => [
        'key' => 'baf37aed803fb1001e493ebd6c4accbb'
    ],
    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'localhost',
                'dbname' => 'magento',
                'username' => 'root',
                'password' => 'root',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1'
            ]
        ]
    ],
    'resource' => [
        'default_setup' => [
            'connection' => 'default'
        ]
    ],
    'x-frame-options' => 'SAMEORIGIN',
    'MAGE_MODE' => 'developer',
    'session' => [
        'save' => 'files'
    ],
    'cache_types' => [
        'config' => 0,
        'layout' => 0,
        'block_html' => 0,
        'collections' => 0,
        'reflection' => 0,
        'db_ddl' => 0,
        'eav' => 0,
        'customer_notification' => 0,
        'config_integration' => 0,
        'config_integration_api' => 0,
        'full_page' => 0,
        'config_webservice' => 0,
        'translate' => 0,
        'vertex' => 0
    ],
    'install' => [
        'date' => 'Thu, 04 Apr 2019 11:03:42 +0000'
    ]
];

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

View solution in original post

2 REPLIES 2

Re: Magento 2.2.8 PHP Parse Error unexpected '=>" in env line 3 setup:upgrade

Changing it to this solved the issue but I'm not sure if there will be any problems with this in the future if anyone knows?

 

<?php
return array (
    'backend' =>
        array (
            'frontName' => 'Michael',
        ),
    'install' =>
        array (
            'date' => 'Thu, 04 Apr 2019 11:03:42 +0000',
        ),
    'crypt' =>
        array (
            'key' => 'baf37aed803fb1001e493ebd6c4accbb',
        ),
    'session' =>
        array (
            'save' => 'files',
        ),
    'db' =>
        array (
            'table_prefix' => '',
            'connection' =>
                array (
                    'default' =>
                        array (
                            'host' => 'localhost', 
                            'dbname' => 'magento', 
                            'username' => 'root', 
                            'password' => 'root', 
                            'model' => 'mysql4',
                            'engine' => 'innodb',
                            'initStatements' => 'SET NAMES utf8;',
                            'active' => '1',
                        ),
                ),
        ),
    'resource' =>
        array (
            'default_setup' =>
                array (
                    'connection' => 'default',
                ),
        ),
    'x-frame-options' => 'SAMEORIGIN',
    'MAGE_MODE' => 'developer',
    'cache_types' =>
        array (
            'config' => 0,
            'layout' => 0,
            'block_html' => 0,
            'collections' => 0,
            'reflection' => 0,
            'db_ddl' => 0,
            'eav' => 0,
            'customer_notification' => 0,
            'config_integration' => 0,
            'config_integration_api' => 0,
            'full_page' => 0,
            'config_webservice' => 0,
            'translate' => 0,
            'vertex' => 0
        ),
);

Re: Magento 2.2.8 PHP Parse Error unexpected '=>" in env line 3 setup:upgrade

Hello @michael_myburgh 

 

Yes there is a mistake in your code which is Return 1;

 

Because here you don't require to do Return a number, May be it is typo error or unknowingly added.

 

Here is the final code which will resolved your error.

 

<?php
return [
   'backend' => [
        'frontName' => 'Michael'
    ],
    'crypt' => [
        'key' => 'baf37aed803fb1001e493ebd6c4accbb'
    ],
    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'localhost',
                'dbname' => 'magento',
                'username' => 'root',
                'password' => 'root',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1'
            ]
        ]
    ],
    'resource' => [
        'default_setup' => [
            'connection' => 'default'
        ]
    ],
    'x-frame-options' => 'SAMEORIGIN',
    'MAGE_MODE' => 'developer',
    'session' => [
        'save' => 'files'
    ],
    'cache_types' => [
        'config' => 0,
        'layout' => 0,
        'block_html' => 0,
        'collections' => 0,
        'reflection' => 0,
        'db_ddl' => 0,
        'eav' => 0,
        'customer_notification' => 0,
        'config_integration' => 0,
        'config_integration_api' => 0,
        'full_page' => 0,
        'config_webservice' => 0,
        'translate' => 0,
        'vertex' => 0
    ],
    'install' => [
        'date' => 'Thu, 04 Apr 2019 11:03:42 +0000'
    ]
];

Hope it helps !

if issue solved,Click Kudos & Accept as Solution