CakePHP .ctp 语法在 Eclipse 中高亮显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5809103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:14:27  来源:igfitidea点击:

CakePHP .ctp syntax highlighting in Eclipse

eclipsecakephp

提问by Webnet

Why CakePHP decided to build their own file format instead of .tpl is beyond me... despite that, i can't get syntax highlighting to work in Eclipse... I've followed this guide: http://planetcakephp.org/aggregator/items/5452-opening-ctp-file-with-syntax-highlight-in-eclipse(dead link) but it doesn't work, I see an error about an unsupported content type for this file. I've added an association to the PHP editor for this file type and it still shows the issue.

为什么 CakePHP 决定构建自己的文件格式而不是 .tpl 超出我的范围......尽管如此,我无法在 Eclipse 中使用语法突出显示......我已经按照本指南进行了操作:http: //planetcakephp.org /aggregator/items/5452-opening-ctp-file-with-syntax-highlight-in-eclipse死链接)但它不起作用,我看到有关此文件不受支持的内容类型的错误。我已为此文件类型添加到 PHP 编辑器的关联,但它仍然显示该问题。

Any ideas on how to get syntax highlighting to work?

关于如何使语法突出显示工作的任何想法?

回答by JohnP

Make sure you have set the correct editor associations and content types

确保您设置了正确的编辑器关联和内容类型

Go to settings (Window -> preferences)

转到设置 ( Window -> preferences)

Content Types

内容类型

  1. Type in Content Typesin the search box (should show under General -> Types
  2. Click on the arrow next to Text, select PHP Content Type
  3. Add *.ctpby clicking on the Add button on the right side
  1. Content Types搜索框中输入(应显示在General -> Types
  2. 单击旁边的箭头Text,选择PHP Content Type
  3. 添加*.ctpAdd按钮通过点击右侧

File Association

文件关联

  1. Type in File Associationsin the search box on the left
  2. Add *.ctp (click the Add button on the top right side)
  3. Associate the proper editor for it by clicking Add (on the bottom right side) and selecting PHP Editor
  1. File Associations左边的搜索框中输入
  2. 添加*.ctp(点击右上角的添加按钮)
  3. 通过单击添加(在右下角)并选择 PHP 编辑器,为其关联合适的编辑器

回答by Jondolar

You can change the extension that CakePHP uses for view files to an extension that Eclipse likes. In the controller (or app_controller) add the following variable:

您可以将 CakePHP 用于视图文件的扩展名更改为 Eclipse 喜欢的扩展名。在控制器(或 app_controller)中添加以下变量:

var $ext = '.tpl';

If you change the extension to "PHP" you may have problems because CakePHP will try to load a class that matches the filename.

如果您将扩展名更改为“PHP”,您可能会遇到问题,因为 CakePHP 会尝试加载与文件名匹配的类。