phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

Simplify class creation

Open Zerotask opened this issue 3 years ago • 0 comments

If you work on bigger projects with complex folder (namespace) structures there is always a manual effort and error source when creating new PHP files. You right-click on a specific folder -> New file.... This will create a new empty file.

There should be an option to create at least something like (for file User.php):

<?php

class User
{
}

Optimally there is also the proper namespace and declare(strict_types=1);. So a perfect empty PHP file (for us) could be:

<?php

declare(strict_types=1);

namespace Company\Service\Utils\Config;

class User
{
}

(and the cursor is directly inside the curly brackets.)

So what are the options to make this available?

  • A code snippet, so you create an empty file and then write something like phpclass
  • A new context menu option New PHP file... (I guess that would be our preferred solution)
  • Override the New file... behavior, if a PHP environment is detected

Zerotask avatar Nov 04 '22 17:11 Zerotask