PHP Use Helper
PHP Use Helper makes it effortless to manage Built with Symfony and Doctrine developers in mind. FeaturesAdd a
|
| Action | Mac | Windows / Linux |
|---|---|---|
| Add use statement | Cmd+Shift+U |
Ctrl+Shift+U |
| Sort use statements | Cmd+Shift+S |
Ctrl+Shift+S |
Right-click Context Menu
All three commands are available from the editor context menu when editing a PHP file:
- PHP: Add use statement
- PHP: Sort use statements
- PHP: Remove unused use statements
Supported Classes
The extension includes presets for the most commonly used classes in Symfony and Doctrine projects.
Symfony
- Controller, Request, Response, JsonResponse, RedirectResponse
- Route (Attribute & Annotation)
- AbstractType, FormBuilderInterface, OptionsResolver
- TextType, EmailType, PasswordType, IntegerType, DateTimeType, SubmitType, ChoiceType, TextareaType
- ValidatorInterface, NotBlank, Length, Email
- UserInterface, PasswordAuthenticatedUserInterface, UserPasswordHasherInterface
- SerializerInterface, EventSubscriberInterface
Doctrine ORM
- EntityManagerInterface, EntityRepository, ServiceEntityRepository
- ManagerRegistry, Paginator
- Mapping: Entity, Column, Id, GeneratedValue, ManyToOne, OneToMany, ManyToMany, JoinColumn, Table
PHP Standard
- DateTime, DateTimeImmutable, DateTimeInterface
- Exception, RuntimeException, InvalidArgumentException, LogicException
Adding Your Own Classes
Open src/extension.js and add entries to the COMMON_CLASSES array:
const COMMON_CLASSES = [
// Add your own classes here
'App\\Service\\MyCustomService',
'App\\Repository\\MyRepository',
...
];
Installation
From VSIX file
code --install-extension php-use-helper-1.0.0.vsix
Or open VSCode → Cmd+Shift+P → Extensions: Install from VSIX...
Requirements
- VSCode
^1.85.0 - A PHP project (Symfony recommended)
License
MIT