php - 如何修复新文件夹项目中未确定的命名空间?

标签 php configuration namespaces phpstorm

我从 phpstorm7 升级到 phpstorm8。现在,每当我在现有文件夹中创建新的 PHP 类时,都会正确插入命名空间。然而,当我创建一个空文件夹并在其中创建一个新类时,命名空间是空的,我必须手动添加它。

在图片中:

  1. 现有文件夹具有命名空间:
    Example of the namesapce being inserted for an existing folder
  2. 同一项目中的新文件夹缺少命名空间。 Example of the namespace not being generated for a new folder

如何让 phpstorm 始终自动生成当前命名空间?

最佳答案

有时 PhpStorm 无法正确检测源目录的适当命名空间。

您可以尝试通过进入 Settings > Project: xxx > Directories 来解决这个问题,单击您的 src/ 目录旁边的小“P”并设置根目录项目的命名空间。

enter image description here (右侧面板中列出的目录可能没有那么多,具体取决于项目的复杂程度)

关于php - 如何修复新文件夹项目中未确定的命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25937005/

相关文章:

c# - 如何在 C# 中为 XPath 添加命名空间?

PHP命名空间从不同目录调用函数

php - 我如何使用 CASE 语句循环遍历这些?

java - 如何在 Android 应用程序中一次更改所有 Activity 转换?

linux - 根据conf文件替换文件的值

configuration - Hadoop/Hive 集群。只有一个节点利用率

php - 从原始 sql 更改为 codeigniters 事件类

php - 克安普 : composer installation issue: module openssl already loaded in Unknown on line 0

javascript - 第一次加载 html 页面时播放声音

php - 使用 PHP 中的动态命名空间前缀解析 XML 元素