Search code examples
javascriptphphtmlcakephpphpstorm

PhpStorm: write in PHP, HTML and JS in ctp file


Using CakePHP to write code, usually *.ctp files contains PHP, HTML and JavaScript code. Unfortunately PhpStorm recognize PHP and HTML only:

PhpStorm example

Of course if I edit a JavaScript-only file (.js) the highlight and autocompletion work.

I tried to follow this answer, but I cannot assign the same extension to multiple languages.

How to edit all the three languages in PhpStorm?


Solution

  • Do the following:

    <?php $this->append('script');?>
    <script type="text/javascript">
    
    jQuery(document).ready(function() {
        ...
    });
    
    </script>
    <?php $this->end();?>