You can tell PHPStorm to ignore undefined variables reports if require on include statement are located in the same execution flow before the variable access. You'll find it in 'Undefined variable' - Ignore 'include' and 'require' statements. It is enabled by default, so you should disable it.

Note: The setting is in File > Settings (Ctrl+Alt+S) > Project Settings > Inspections > PHP > Undefined > Undefined variable