Not all include files are created equal.

I created a class in a separate file and have it in the same directory as the PHP page including it. I named the include file as "sql.include" and PhpStorm does not like this. I included the second file in the main php page...

include_once("sql.include");
$sql = new sql_connection("databasename");

When using the class in the main PHP, the IDE reports "Undefined class". If i rename the include file from "sql.include" to "sql.inc" and change the include_once() to match then the warning goes away and the IDE is happy, it finds the class.

Why doesn't PhpStorm pay attention to the include_once() line and parse the class name from the file given?

Is there a setting in PhpStorm where i can tell it that ".include" is an include file same as ".inc"? However IMO it should just detect / read the file listed in the include_once() line.

 

0
2 comments

Hi there,

  1. PhpStorm parses files based on their File Type.
  2. There are no assigned File Type for files with .include extension (but there is one for .inc).

If you need to use such a custom extension for a file with PHP code inside -- go and add a rule at Settings (Preferences on macOS) | Editor | File Types -- locate PHP file type and add *.include pattern there.

 

1

Thank you, that is what i was looking for.

0

Please sign in to leave a comment.