This is a Sublime Text package which includes handy snippets for doing Symfony2 framework development.
If you have the Package Control package installed, you can install Symfony2 Snippets from inside Sublime Text itself. Open the Command Palette and select "Package Control: Install Package", then search for Symfony2 Snippets.
If you haven't got Package Control installed you will need to make a clone of this repository into your packages folder, like so:
git clone https://github.com/raulfraile/sublime-symfony2 symfony2-snippets
All shortcuts start with the sf prefix and are both short and intuitive:
sfcontroller
namespace VendorName\Bundle\BundleNameBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ControllerNameController extends Controller
{
public function indexAction()
{
return $this->render('VendorNameBundleNameBundle:ControllerName:index.html.twig');
}
}sfem
$em = $this->getDoctrine()->getEntityManager();sfrepo
$em->getRepository('Bundle:Repository');sfforward
$this->forward('TestBundle:Folder:view', array());sfredirect
$this->redirect($this->generateUrl('route'));sfrender
$this->render('TestBundle:Folder:view.html.twig', array());sfsession
$this->getRequest()->getSession();sfsetflash
this->get('session')->setFlash('notice', 'message');sfform
namespace VendorName\Bundle\BundleNameBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class FormNameType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
}
public function getDefaultOptions(array $options)
{
return array(
'data_class' => 'VendorName\\Bundle\\BundleNameBundle\\Entity\\FormName',
);
}
public function getName()
{
return 'formName';
}
}sfentity
**
* @ORM\Entity
* @ORM\Table(name="name")
*/sfidcolumn
/**
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/sfstringcolumn
/**
* @ORM\Column(type="string", length=100)
*/sfdecimalcolumn
/**
* @ORM\Column(type="decimal", scale=${1:2})
*/sfstextcolumn
/**
* @ORM\Column(type="text")
*/sfroute
route_name:
pattern: /url
defaults: { _controller: AcmeTestBundle:Test:action }If you miss something, feel free to fork this repository and send a PR with your awesome snippets for Symfony2 :)