2

My existing files miss copyright info. I want to add a licence header to severals files in a project with Phpstorm / other JetBrains IDE.

This page doesn't help: https://www.jetbrains.com/idea/help/topicId609815.html

Anyone know the process please?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
  • 5
    Try File | Settings (Preferences for Mac) | Editor | File and Code templates | Includes -> PHP File header – Kootli Feb 22 '15 at 10:48

2 Answers2

2

In 2016 JetBrains added a Copyright tool exactly for this purpose.

See https://blog.jetbrains.com/phpstorm/2016/01/managing-copyright-notices-in-phpstorm/ for more information.

arkuuu
  • 619
  • 7
  • 23
0

I have the same requirement, but the closest thing I could get is to use the Live Templates feature. Basically I added a new Template under the PHP Group with the abbreviation copyright and the following text

/**************************************************************************
 * Copyright (C) $user$, Inc - All Rights Reserved
 *
 * <omitted copyright blah>
 *
 * @file        $file$
 * @author      $user$
 * @site        <my website>
 * @date        $date$
 */

Unfortunately it seems impossible to use Template Variables such as ${NAME} in the context of a Live Template, so you are forced to stick with the provided expressions. In this case I used fileName(), user() and date() which were enough for my case.

Finally you can type copyright and press Tab to generate the header.

mauricius
  • 106
  • 3