An Oracle blog about NetBeans for PHP

Initial support for Smarty available

Guest Author

Thanks to Martin Fousek, we now have support for Smarty Template Engine. He also wrote this blog post:

Base support of another PHP Framework in NetBeans is on the way. It's presentation framework Smarty which is well-known tool for separating application and visual logic. First versions of the support we just added to the development Update Center so should be available in plugins of every dev build of NetBeans IDE under the name "PHP Smarty Framework".

For now there are these functions for .tpl files:

  • recognizing as a Smarty templates and creating them via New File Wizard
  • syntax highlighting with possibility to change default colors in Tools > Options > Fonts&Colors - SMARTY Templates
  • HTML functionality (HTML navigator, HTML code completion)
  • PHP syntax highlighting for {php}{/php} tags

Functions which aren't supported yet:

  • code completion for Smarty keywords and PHP code
  • using another than standard Smarty delimiters

Syntax highlighting for Smarty templates

Syntax highlighting of embedded PHP in .tpl files

Please report all issues you find in NetBeans IssueZilla > contrib > Smarty, thanks.

Join the discussion

Comments ( 47 )
  • Tom Thursday, March 25, 2010

    I have NetBeans code-templates for autocompletion in Smarty-files. If you want them, just drop me a line. Should be copy'&'paste.

  • eddie Thursday, March 25, 2010

    Again, simply awesome. Thanks!

    By the way - I wanted all the goodies from 6.9 but was afraid that development builds will be unstable. I'm running 6.9 a week and everything's fine so far :-)

    (There are occasional freezes for few seconds though).

  • Pet Thursday, March 25, 2010

    Where is option for defining other as standard delimiters?

  • Pet Thursday, March 25, 2010

    Where is option for defining other as standard delimiters?

    I love NB more and more!

  • Pet Thursday, March 25, 2010

    Thanks for this!!!

    Where is option for defining other as standard delimiters?

    I love NB more and more!

  • Pet Thursday, March 25, 2010


    Where is the option for defining custom delimiters?

    Love NB more and more

  • ezod Thursday, March 25, 2010

    Great work guys!

  • Franquin Thursday, March 25, 2010

    This is the greatest news about Netbeans for a long time :-)

  • Crempa Thursday, March 25, 2010

    Hi, great news!

    Do you plan support for \*.phtml files too? Some frameworks with smarty-like syntax use it instead of \*.tpl.


  • SmartyMan Thursday, March 25, 2010

    What file extensions are supported for Smarty templating, only \*.tpl ? I have my templates in \*.phtml file, is it posible to configure smarty support for other file extensions ?

  • Tomas Mysik Thursday, March 25, 2010

    To Crempa: Not for now, it would be quite difficult so only TPL files are supported now.

  • Tomas Mysik Thursday, March 25, 2010

    To SmartyMan: I already answered in my previous comment.

  • Urkman Thursday, March 25, 2010


    what's about a new stable build? I'm still using 6.9M1, because there is no stable build for a long long time...


  • FDisk Thursday, March 25, 2010
  • Martin Fousek Thursday, March 25, 2010

    To Pet: As was mentioned above, custom delimiters aren't supported yet. It should be supported in next version of the plugin.

  • Martin Fousek Thursday, March 25, 2010

    To Crempa and SmartyMan: The only way how to do that for now is to set .phtml

    files as text/x-tpl MIME type in Options -> Miscellaneous -> Files. But

    then you can't use .phtml files for PHP code.

  • Jeff Whiting Thursday, March 25, 2010

    That is awesome. Thanks!

    But you HAVE TO ADD SUPPORT FOR CUSTOM DELIMITERS! Sorry to shout that but that is so important. We like many others don't use the standard smarty delimiters because they don't play nicely with JavaScript. So please, please add that support.

    Once again thanks for you work.

  • Martin Fousek Thursday, March 25, 2010

    To FDisk: For beta or release of NB6.9 should be support of Smarty framework

    available on beta Update Center.

  • guest Thursday, March 25, 2010


    Please, post it on forum or mailing list or somewhere else

  • FDisk Thursday, March 25, 2010

    I can not find the smarty plugins. I downloaded the latest - NetBeans IDE Dev (Build 201002152000)

    Then I checked for updates. Then I chose Tools> Plugins> Available Plugins

    and entered into the search box: smarty

    Could you give us a link to the installation manual?

    Greetings from Lithuania.

  • Martin Fousek Friday, March 26, 2010

    To FDisk: I'm affraid that you have version from February (2010 02 15). The lastest builds you can find here: http://bits.netbeans.org/download/trunk/nightly/latest/

  • NB Friday, March 26, 2010

    cool, but without custom delimiters not really useful for me...

  • Andreas Burø Friday, March 26, 2010

    Thanks. Seem to be working pretty smooth.

  • Martin Fousek Friday, March 26, 2010

    I suppose that custom delimiters could be there in one or two weeks.

  • Pet Friday, March 26, 2010

    @Martin Fousek

    Thanks! It's most important option in this plugin. I mean autocompletion and goto's are important as well :)

  • Winsik Wednesday, March 31, 2010

    Greetings from Brno :)

    Thank you for creating this plugin, it will be very usefull for me.

    Did I understand well you ate planning option of changing standard delimiters to another one ? I use <{ ... }> instead of standard {...} will it be possible to use your plugin ?

    Thank you for your work.



  • Martin Fousek Wednesday, March 31, 2010

    To Winsik: Right. By the way, thanks to Tomas Mysik was implemented needed NB API. So only implementation in Smarty plugin remains.

  • Sklodowski Wednesday, March 31, 2010

    What about CakePHP support? If I'm not mistaken, it is planned for Netbeans 6.9.

  • Tomas Mysik Thursday, April 1, 2010

    To Sklodowski:

    Unfortunately, CakePHP won't be supported by NB 6.9.

  • pcdinh Sunday, April 4, 2010


    Why does the standard PHP template not get the same behavior? No highlight or block matching for

    <?php foreach (): ?>

    <?php endforeach; ?>


    <?php if (): ?>

    <?php endif; ?>

    It is really a big mistake because Smarty does get as much attention as in the past. Standard PHP template is much more popular.


  • Tom Thursday, April 8, 2010

    @pcdinh What's your point? It already IS highlighted! Even in older versions of NetBeans it works fine.

    Maybe you forgot to register the file-extension as PHP-file? You might want to try \*.php instead!

  • pcdinh Thursday, April 8, 2010


    I attached a screenshot taken for Netbeans 6.8 for your reference.


    As you can see, NB 6.8 does not highlight the blocks: <?php if (...): ?> and <?php endif; ?>

    The same in Netbeans 6.9 daily builds. (I reinstall my Netbeans 6.9 everyday)

    My point is that if you support if/else/endif, foreach/endforeach tag highlighting for Smarty, you should do the same as in pure PHP template because it is much more popular. Smarty does not gain mindset in PHP community recent years because of the increasing MVC adoption.

    Although people does not need Smarty any more and they know how to create PHP templates in a smarter and more discipline manner using pure PHP template and MVC, the support of if/else/endif tag highlighting is really expected.


  • Pet Friday, April 9, 2010


    Well, syntax is recognized, only background is not of different color. IMO, you should file an issue for this, as people did for SMARTY support. SMARTY could be bad or good, but as developer you need support for it. Personally, I'm happy NB support SMARTY

  • Petr Pisl Tuesday, April 13, 2010
  • Pet Tuesday, April 13, 2010

    I've updated plugin, and now delimiter can be configured. Could we have multiple valid delimiter?

    I have to deal with different templates, which using different delimiters.


  • Sabyasachi Ruj Wednesday, April 14, 2010

    Not able to configure the delimiter. :(

    I have installed the Version: 1.20 of PHP Smarty Framework today.

    I am not able to see the template for "Smarty Template". The "open in editor" button is disabled for that template.

  • Martin Fousek Thursday, April 15, 2010

    Custom delimiters will be published on the blog today. Please, let's discuss everything about them in new entry.

    To Sabyasachi Ruj: Maybe it will be because you haven't any SMARTY template within first two dir-levels in your project directory.

  • Sabyasachi Ruj Friday, April 16, 2010


    Waiting for the blog post.

    "To Sabyasachi Ruj: Maybe it will be because you haven't any SMARTY template within first two dir-levels in your project directory."

    I have created a sample test project where I have a test.tpl in the same directory where "nbproject" directory is.

    This is my directory structure:

    --> smarty-test/

    ----> nbproject/

    ----> index.php

    ----> test.tpl

    If I am correct, by editing the template only I could configure delimiters. Am I right?

  • Ali Monday, April 19, 2010

    I've been waiting for this feature!

    NetBeans IDE Dev (Build 201004190200), SMARTY plugin 1.20:

    I wanted to set my .phtml files to be recognized as SMARTY templates. I followed instructions here (Options -> Miscellaneous -> Files: then set .phtml files as text/x-tpl MIME type), but nothing happened. At the same time it works if I rename .phtml file to .tpl.

    One more thing: In .tpl file I can see highlighting as it's shown here, but when click on smarty function start (e.g. {if}) editor doesn't show the end ({/if}. I think it's important when you have complicated nested structure of conditions or foralls. Do you plan support for this?

  • masev Monday, May 10, 2010

    I can't find smarty in plugin update center of netbeans 6.9. Any way to install the plugin on this version ?

    Thanks !!

  • Slava Monday, May 31, 2010

    I downloaded NetBeans Dev 201005290001 and didn't find Smarty plugin there. How I can get Smarty support in this version?


  • Piotr Tuesday, June 8, 2010


    Could You add support for Twig template language http://www.twig-project.org/ ?

    It will be very nice :)

  • Marco Thursday, June 24, 2010

    Does anyone know when autocompletion might be available with this plugin in netbeans 6.9?

  • Planzelle Monday, August 23, 2010

    My workaround for the missing codecompletion:

    - Use code template for plain text

    - File > New File > Other > Empty File

    - Save file without the .tpl extension

    - now use shortcut + TAB for snippet

    - rename file with .tpl suffix

    As mentioned - only a workaround.

    You can store the template as PHP template, but then you need the openening and closing php-tags which must be removed after inserting the template (since we want a smarty template) plus the rename procedure - so a plain text file is easier.

  • Piotr Monday, September 27, 2010

    Look at http://www.twig-project.org/book/06-Recipes.

    // Twig syntax

    'tag_comment' => array('{#', '#}'),

    'tag_block' => array('{%', '%}'),

    'tag_variable' => array('{{', '}}'),

    // Ruby erb syntax

    'tag_comment' => array('<%#', '%>'),

    'tag_block' => array('<%', '%>'),

    'tag_variable' => array('<%=', '%>'),

    // SGML Comment Syntax

    'tag_comment' => array('<!--#', '-->'),

    'tag_block' => array('<!--', '-->'),

    'tag_variable' => array('${', '}'),

    // Smarty like

    'tag_comment' => array('{\*', '\*}'),

    'tag_block' => array('{', '}'),

    'tag_variable' => array('{$', '}'),

  • Gregg Sunday, February 6, 2011

    At first I couldn't find the PHP Smarty Framework while searching via the 6.9.1 IDE. Turns out the plugin is listed under the NetBeans Beta repository. Is this plugin (version 1.26) still considered a beta?

  • Martin Fousek Tuesday, March 8, 2011

    PHP Smarty Framework plugin was placed on Beta UC because it was easier due to quality (for stable UC it has to be tested by QE and there wasn't resources for this). For 7.0 release it should be available on Plugin Portal UC.

    @Piotr - Sorry, not planned for now but feel free to enter enhancement http://netbeans.org/bugzilla/enter_bug.cgi?product=contrib&component=Smarty&cf_bug_type=ENHANCEMENT.

    @Marco - Lightweight CC is done for 7.0.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.