muuucho
(Marten H Hansson)
September 18, 2015, 12:25pm
1
When i try to run the country script that I (or gii) created in The definitive guide/Getting started/Generating Code with gii, I get the following error:
PHP Parse Error – yii\base\ErrorException
syntax error, unexpected ‘namespace’ (T_NAMESPACE)
in C:\xampp\htdocs\basic\controllers\CountryController.php
I enter "basic/web/index.php/country/index" in my browser.
"basic/web/index.php/country" gives the same error.
Anyone?
Hi!
Simple issue.
The namespace in these files is wrong or not set.
According to what you have posted…
In file \basic\controllers\CountryController.php add at directly at the top:
<?php
namespace app\controllers;
Regards
muuucho
(Marten H Hansson)
September 20, 2015, 6:21am
3
Thanks, but that line is already there.
muuucho
(Marten H Hansson)
September 20, 2015, 6:35am
4
btw, the following variables might be of interest:
‘DOCUMENT_ROOT’ => ‘C:/xampp/htdocs’,
'REQUEST_SCHEME' => 'http',
'CONTEXT_PREFIX' => '',
'CONTEXT_DOCUMENT_ROOT' => 'C:/xampp/htdocs',
'SERVER_ADMIN' => 'postmaster@localhost',
'SCRIPT_FILENAME' => 'C:/xampp/htdocs/basic/web/index.php',
'REMOTE_PORT' => '57555',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'REQUEST_METHOD' => 'GET',
'QUERY_STRING' => '',
'REQUEST_URI' => '/basic/web/index.php/country/index',
'SCRIPT_NAME' => '/basic/web/index.php',
'PATH_INFO' => '/country/index',
'PATH_TRANSLATED' => 'C:\\xampp\\htdocs\\country\\index',
'PHP_SELF' => '/basic/web/index.php/country/index',
muuucho
(Marten H Hansson)
September 21, 2015, 7:05am
5
Should have read your answer better, especially "directly at the top"
I found the letter r outside my comments above the namespace row.
Many thanks!