Skip to content

pylebecq/sublime-symfony2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

This is a Sublime Text package which includes handy snippets for doing Symfony2 framework development.

Installation

With Package Control

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.

Without Package Control

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

Shortcuts

All shortcuts start with the sf prefix and are both short and intuitive:

Controller

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');

Forms

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';
    }
}

Doctrine

Annotations

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")
 */

YAML

sfroute

route_name:
    pattern:   /url
    defaults:  { _controller: AcmeTestBundle:Test:action }

Contribute

If you miss something, feel free to fork this repository and send a PR with your awesome snippets for Symfony2 :)

Contributors list

About

A Sublime Text bundle for Symfony2 development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published