Fork me on GitHub

PHP

Templates

# Symfony\Bundle\FrameworkBundle\Controller\Controller
# Symfony\Bundle\TwigBundle\TwigEngine
$this->render('<template.html.twig>')
$this->renderView('<template.html.twig>')

based on BundleInterface, addPath of container and custom path of settings

  • goto - Template file
  • complete - Template names
  • annotator - Mark missing template and provides twig template create action
/**
 * @Template()
 */
public function indexAction() { }
/**
 * @Template("<template.html.twig>")
 */
public function indexAction() { }
  • goto - Template on click of @Template
  • complete - Template names
  • annotator - Mark missing template and provides twig template create action
'<template.html.twig>'

all string ending with .twig provides goto

Service / Parameter

# Symfony\Component\DependencyInjection\ContainerInterface::get
$this->container->get('<service_name>');
$this->container->get(SERVICE::NAME);
$this->container->get($this->name);
  • goto - Goto service class
  • complete - Service name
  • annotator - Mark missing service
  • type - The class type of service definition
# Symfony\Component\DependencyInjection\ContainerInterface::has
$this->container->has('<service_name>');
  • goto - see above
  • complete - see above
# \Symfony\Component\DependencyInjection\ContainerInterface::*
$this->container->getParameter('<parameter>');
$this->container->hasParameter('<parameter>');
  • complete - Defined parameter

Container Builder

# \Symfony\Component\DependencyInjection\Reference
new Reference('<service_name>');

# \Symfony\Component\DependencyInjection\Definition
new Definition('<class>');

# \Symfony\Component\DependencyInjection\Alias
new Alias('<service_name>');

# \Symfony\Component\DependencyInjection\ContainerBuilder::setAlias
$container->setAlias('alias', '<service_name>');

# \Symfony\Component\DependencyInjection\ContainerBuilder::findDefinition
$container->findDefinition('<service_name>');

# \Symfony\Component\DependencyInjection\ContainerBuilder::hasDefinition
$container->hasDefinition('<service_name>');

# \Symfony\Component\DependencyInjection\ContainerBuilder::getDefinition
$container->getDefinition('<service_name>');

# \Symfony\Component\DependencyInjection\ContainerBuilder::findTaggedServiceIds
$container->findTaggedServiceIds('<tag>');
  • goto - tags: all tagged services

Note

All ContainerBuilder calls provides access to service-index which includes private ones

Doctrine

$em->getRepository(Entity::class);
$em->getRepository($this->foo);
$em->getRepository('<FooBundle:Entity>');
  • goto - Go to entity class
  • complete - All classes in Doctrine entity namespaces as shortcut name
  • type - Return repositoryClass of entity supported parser in order: annotations, yaml, CLASSRepository

Note

Entities in subfolder are not supported because of PhpStorm issues

$em->getRepository('<FooBundle:Entity>')->find(1);
$em->getRepository('<FooBundle:Entity>')->findOneBy(array());
$em->getRepository('<FooBundle:Entity>')->findBy(array());
$em->getRepository('<FooBundle:Entity>')->findAll();
  • type - Return Entity or Entity[]
# Doctrine\Common\Persistence\ObjectManager::find
$em->find('FooBundle:Invite', 1) ;
  • type - Return Entity
  • goto - see above
  • type - see above

Translation

#Symfony\Component\Translation\Translator::trans
#Symfony\Component\Translation\Translator::transChoice

$t->trans('translation.key', array(), '<Domain>')
$t->transChoice('translation.key', 2, array(), '<Domain>')
  • goto - Domain file like yaml or other, from container file
  • complete - Domain file like yaml or other, from container file
  • annotator - Mark missing domain files
# Symfony\Component\Translation\Translator::trans
# Symfony\Component\Translation\Translator::transChoice

$t->trans('<translation.key>', array(), 'Domain')
$t->transChoice('<translation.key>', 2, array(), 'Domain')
  • goto - Yaml Key-Value of Domain, default messages or trans_default_domain of current file
  • complete - All known translation key filtered by domain name
  • annotator - Mark missing translation and provide quick fix, which create key inside domain file

Routing

# Symfony\Bundle\FrameworkBundle\Controller\Controller::generateUrl
$this->generateUrl('_configurator_final', array('parameter' => 'test'))
  • goto - Controller action method and parameter
  • complete - Routing name and parameter of eg. appDevUrlGenerator.php
  • annotator - Mark missing routing name
# Symfony\Bundle\FrameworkBundle\Controller\Controller::forward
$this->forward('<controller_action>', array('parameter' => 'test'))
  • goto - Controller action method
  • complete - Controller names of Bundle structure or controller services as shortcut
# Symfony\Bundle\FrameworkBundle\Controller\Controller::forward
# Symfony\Bundle\FrameworkBundle\Controller\Controller::generateUrl
$this->generateUrl('<controller_action>', array('<parameter>' => 'test'))
  • goto - Method Parameter
  • complete - Parameters of route

Forms

# Symfony\Component\Form\FormBuilderInterface::add
$builder->add('field', '<complete>');
  • goto - resolved class
  • complete - Registered FormTypes aliases
# Symfony\Component\Form\FormBuilderInterface::add
$builder->add('field', 'button' , array(
  'label' => '<translation_key>',
  'help_inline' => '<translation_key>',
  'help_block' => '<translation_key>',
  'translation_domain' => '<translation_domain>',
));
  • goto - Translation definition
  • complete - Translation key or domain

Note

also translation_domain inside OptionsResolverInterface::setDefaults is supported for filter

# Symfony\Component\OptionsResolver\OptionsResolverInterface::setDefaults
$resolver->setDefaults(array(
  'data_class' => '<entity_class>'
));

# Symfony\Component\Form\FormBuilderInterface::add
$builder->add('field', 'form_alias'|FormTypeInterface, array(
  'class' => '<entity_class>'
));
  • goto - Class definition
  • complete - Class name of doctrine namespaced entities
# Symfony\Component\Form\FormBuilderInterface::add
$builder->add('field', 'form_alias'|FormTypeInterface, array(
  '<option>' => ''
));
  • goto - tagged form extension with form.type_extension or getParent tree of known form_type
  • complete - name for option
# Symfony\Component\OptionsResolver\OptionsResolverInterface::setDefaults
$resolver->setDefaults(array(
  '<form_options|form_extensions>' => ''
));

# Symfony\Component\Form\FormBuilderInterface::add
$builder->add('field', 'form_alias'|FormTypeInterface, array(
  '<form_options|form_type_options|form_extensions>' => ''
));
  • goto - array definition of option
  • complete - all matched form options
# Symfony\Component\Form\FormFactory::create
# Symfony\Component\Form\FormFactory::createNamedBuilder
# Symfony\Bundle\FrameworkBundle\Controller\Controller::createForm
$this->createForm('button', "type", array(
  '<option>' => 'foo'
));
  • goto - array definition of option
  • complete - all matched form options

Note

Types are resolve on parents and other condition

# \Symfony\Component\Form\Form::get
# \Symfony\Component\Form\Form::has
$form->get('<foo>');

EventDispatcher

# Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents
return array(
  '<event_name>' => array()
);
# Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch
$this->get('event_dispatcher')->dispatch('<event_name>')
  • goto - All class that use same event name
  • complete - Event name

Class

class FlashListener implements EventSubscriberInterface {}
../../_images/service_class_definition.png
  • lineMarker - Mark line and provide goto if a service is known definition
  • goto - class service definition

Note

Includes private services