I study OOP by video and the author uses PhPStorm there, I have the same Sublime Text3 and when I run index.php from a local server in the browser, I get the following error:

"Fatal error: Wanted: \ domains \ integrity.ru \ app \ App.php on line 3"

Moreover, if you run separately $app = new liw\core\App(); then everything works. The browser displays a string with text. What is wrong with the second App.php-php file, because they are almost identical and have the same App name? One is in the folder: vendor \ liw \ core \ App.php, the other in app \ App.php

File: app \ App.php

 <?php namespace app; class App { public function __construct() { echo 'Я нахожусь в пакете app'; } } 

File: vendor \ liw \ core \ App.php

 <?php namespace liw\core; class App { public function __construct() { echo 'Я нахожусь в пакете liw/core'; } } 

File: index.php

 <?php require '../vendor/liw/core/App.php'; require '../app/App.php'; $app = new liw\core\App(); echo '<br>'; $app2 = new app\App(); 

    1 answer 1

    https://secure.php.net/manual/ru/language.namespaces.definition.php

     <html> <?php namespace MyProject; // fatal error - объявление пространства имен должно быть первым выражением в скрипте ?> 

    all echo must be after namespace declarations.