Ⅰ. 插件描述
Symfony 3 Vim pluginⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'qbbr/vim-symfony'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'qbbr/vim-symfony'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'qbbr/vim-symfony'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/qbbr/vim-symfony
Ⅳ. 文档说明
# Symfony Vim plugin
Autocomplete routes and services
<C-x><C-u>
Symfony shell
sf4 not supported, because new sf console does not exist "-s" option.
<C-f>
Jumps
<leader>v
- jump to controller from routing.yml
- jump to view (twig) from controller
- jump to view (twig) from view (twig)
Examples:
_welcome:
pattern: /
defaults: { _controller: AcmeDemoBundle:Welcome:index } # cursor at this line
# will open: src/Acme/DemoBundle/Controller/WelcomeController.php
class DefaultController extends Controller
{
public function indexAction()
{
// cursor here and press <leader>v
// will open: src/Acme/DemoBundle/Resources/views/Default/index.html.twig
}
}{% extends "AcmeDemoBundle::layout.html.twig" %}
{# will open: src/Acme/DemoBundle/Resources/views/layout.html.twig #}Snippets
Annotations
@a- @Assert\@o- @ORM\@oc- @ORMColumn()@oe- @ORMEntity(repositoryClass="")@og- @ORMGeneratedValue(strategy="AUTO")@oi- @ORMId@olife- @ORMHasLifecycleCallbacks()@ot- @ORMTable(name="")@r- @Route("")@rn- @Route("", name="")@m- @Method("")@t- @Template()@pc- @ParamConverter("")
Use statements
usearray- use DoctrineCommonCollectionsArrayCollection;useassert- use SymfonyComponentValidatorConstraints as Assert;usecache- use SensioBundleFrameworkExtraBundleConfigurationCache;usecontroller- use SymfonyBundleFrameworkBundleControllerController;usefile- use SymfonyComponentHttpFoundationFileUploadedFile;usemethod- use SensioBundleFrameworkExtraBundleConfigurationMethod;usenotfound- use SymfonyComponentHttpKernelExceptionNotFoundHttpException;useorm- use DoctrineORMMapping as ORM;useparamconverter- use SensioBundleFrameworkExtraBundleConfigurationParamConverter;userequest- use SymfonyComponentHttpFoundationRequest;useresponse- use SymfonyComponentHttpFoundationResponse;usejsonresponse- use SymfonyComponentHttpFoundationJsonResponse;useroute- use SensioBundleFrameworkExtraBundleConfigurationRoute;usesecurity- use SensioBundleFrameworkExtraBundleConfigurationSecurity;usetemplate- use SensioBundleFrameworkExtraBundleConfigurationTemplate;
Controller
controller- controller skeleton classdump,d- dump() functionget- $this->get('')am- action method for controllerem- $em = $this->getDoctrine()->getManager();notfound- throw $this->createNotFoundException('');redirect- $this->redirectToRoute('');repository- $this->getDoctrine()->getRepository('')
Form
form- form type skeleton class
Text Fields
texttype- use SymfonyComponentFormExtensionCoreTypeTextType;textareatype- use SymfonyComponentFormExtensionCoreTypeTextareaType;emailtype- use SymfonyComponentFormExtensionCoreTypeEmailType;integertype- use SymfonyComponentFormExtensionCoreTypeIntegerType;moneytype- use SymfonyComponentFormExtensionCoreTypeMoneyType;numbertype- use SymfonyComponentFormExtensionCoreTypeNumberType;passwordtype- use SymfonyComponentFormExtensionCoreTypePasswordType;percenttype- use SymfonyComponentFormExtensionCoreTypePercentType;searchtype- use SymfonyComponentFormExtensionCoreTypeSearchType;urltype- use SymfonyComponentFormExtensionCoreTypeUrlType;rangetype- use SymfonyComponentFormExtensionCoreTypeRangeType;
Choice Fields
choicetype- use SymfonyComponentFormExtensionCoreTypeChoiceType;entitytype- use SymfonyBridgeDoctrineFormTypeEntityType;countrytype- use SymfonyBridgeDoctrineFormTypeCountryType;languagetype- use SymfonyBridgeDoctrineFormTypeLanguageType;localetype- use SymfonyBridgeDoctrineFormTypeLocaleType;timezonetype- use SymfonyBridgeDoctrineFormTypeTimezoneType;currencytype- use SymfonyBridgeDoctrineFormTypeCurrencyType;
Date and Time Fields
datetype- use SymfonyComponentFormExtensionCoreTypeDateType;datetimetype- use SymfonyComponentFormExtensionCoreTypeDateTimeType;timetype- use SymfonyComponentFormExtensionCoreTypeTimeType;birthdaytype- use SymfonyComponentFormExtensionCoreTypeBirthdayType;
Other Fields
checkboxtype- use SymfonyComponentFormExtensionCoreTypeCheckboxType;filetype- use SymfonyComponentFormExtensionCoreTypeFileType;radiotype- use SymfonyComponentFormExtensionCoreTypeRadioType;
Field Groups
collectiontype- use SymfonyComponentFormExtensionCoreTypeCollectionType;repeatedtype- use SymfonyComponentFormExtensionCoreTypeRepeatedType;
Hidden Fields
hiddentype- use SymfonyComponentFormExtensionCoreTypeHiddenType;
Buttons
buttontype- use SymfonyComponentFormExtensionCoreTypeButtonType;resettype- use SymfonyComponentFormExtensionCoreTypeResetType;submittype- use SymfonyComponentFormExtensionCoreTypeSubmitType;
Base Fields
formtype- use SymfonyComponentFormExtensionCoreTypeFormType;