HTML, PHP completions


#1

Hello,
How can i do for php works like html.
Example:
html

header.header + Tab gives **<header class="header"></header>**

Coorect
php

header.header + Tab gives  header.<header></header>

Not Correct
Thanks for yoiu help
Regards


#2

Is this provided by a package, or your own snippets?


#3

By a package, i suppose
Here is my emmet packages:
emmet and emmet-snippets-compatibility.
Here is my snippets:

'.text.html.basic, .php':
  'HTML5':
      'prefix': 'html5'
      'body': """
      <!DOCTYPE html>
      <html lang="fr">
      <head>
         <meta charset="UTF-8">
         <meta name="viewport" content="width=device-width, initial-scale=1.0">
         <meta http-equiv="X-UA-Compatible" content="ie=edge">
         <title>Document</title>
      </head>
      <body>

      </body>
      </html>
      """
  'div class':
      'prefix': 'cl'
      'body': """
      <div class="${1}">\n\t\t${0}\n</div><!-- .${1} -->
      """
  'div id':
      'prefix': 'id'
      'body': """
      <div id="${1}">\n\t\t${0}\n</div><!-- #${1} -->
      """
#----- PHP -----
'.text.php':
   'IF':
      'prefix': 'if'
      'body': """
      <?php if (${1:condition}): ?>

      <?php endif ?>
      """
   'IF-ELSE':
      'prefix': 'ife'
      'body': """
      <?php if (${1:condition}): ?>
         $0
      <?php else: ?>
         $0
      <?php endif ?>
      """
   'IF-ELSE-IF':
      'prefix': 'ifei'
      'body': """
      <?php if (${1:condition}): ?>
         $0
      <?php elseif (${2:condition}): ?>
         $0
      <?php endif ?>
      """
   'ECHO':
      'prefix': '?'
      'body': '<?= $0 ?>'

Best regards


#4

According to the emmet documentation, the default keybinding only works for HTML, CSS, Sass/SCSS, and Less. Follow the instructions on that page to make it work for PHP.


#5

Thanks, but in Sublime Text, it works fine in html or php. I use atom due to a bug with my php version (7.2.2).
This is the last bothersome thing in atom.


#6

Apparently the Atom package was implemented differently. As stated in the documentation I linked, you can change that.


#7

If you beleive it to be a bug in emmet, I suggest you raise an issue on the relevant repository.

If you do, be sure to explain exactly what is happening, what you expect, why you expect it, the steps to reproduce from a blank file, etc. If you just say what you said here, you are likely to annoy the maintainers before they even consider it.


#8

I have reinstalled emmet and emmet-snippets-compatibility, it seems work fine.
The problem is that css don’t work very well.