Giter Site home page Giter Site logo

phpstorm-settings's Introduction

PhpStorm Live Templates (+ other settings)

This repository includes live templates for PhpStorm (and may contain other settings in the future).

Share your Favorite Settings! This isn't meant to be a readonly repository. Have something you love about your PhpStorm setup? Create a pull request and share it.

See the Live Templates

Installation

  1. Go to PhpStorm Preferences | Tools | Settings Repository

  2. Add Read-only Source https://github.com/knpuniversity/phpstorm-settings

  3. Restart PhpStorm

You can see and manage all the snippets under the Preferences | Editor | Live Templates

Live Templates

Frontend Templates

lorem

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Symfony Templates

formhandle

Adds controller form-handling code

$form = $this->createForm($CLASSNAME$::class);

$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
    // todo - do some work, like saving stuff

    $this->addFlash('success', '$SUCCESSMESSAGE$');

    return $this->redirectToRoute('$ROUTENAME$', []);
}

formrow

{{ form_row(form.$FIELD$) }}

formrowfull

Renders widget/label/errors

<div class="form-control">
    {{ form_label(form.$FIELD$) }}
    {{ form_widget(form.$FIELD$) }}
    {{ form_errors(form.$FIELD$) }}
</div>

repofind

Queries from a doctrine repository in a controller

$this->getDoctrine()
    ->getRepository('$REPO$')->$METHOD$($ARG$);

rendertwig

Renders a Twig template from a controller

return $this->render('$TEMPLATE$', [
    $END$
]);

404unless

404 if statement for your controller

if ($CONDITION$) {
    throw $this->createNotFoundException($MESSAGE$);
}

include

{{ include('$TEMPLATE$') }}

method

@Method("$METHOD$")

path

{{ path('$ROUTE$', { $END$ }) }}

render

{{ render(controller('$CONTROLLER$', { $END$ })) }}

route

@Route("/$PATH$", name="$NAME$")

action

Creates a controller action.

/**
 * @Route("/$PATH$", name="$ROUTE_NAME$")
 */
public function $NAME$Action()
{
    $END$
}

service

Creates a YML service

$NAME$:
    class: $CLASS$
    arguments:
        - '$ARG1$'

tags

Yaml service tags

tags:
    - { name: $TAGNAME$ }

createquery

Query objects in repositories with DQL

$this->getEntityManager()
    ->createQuery('SELECT $ALIAS$
                   FROM $ENTITY$ $ALIAS$
                   WHERE $ALIAS$.$PROPERTY$ = :$PARAMETER$')
    ->setParameter('$PARAMETER$', $ARGUMENT$)
    ->execute();

getem

$em = $this->getDoctrine()->getManager();

getrepo

$em->getRepository('$ENTITY$');

doctrinecolumn

Adds a property with @ORM annotations

/**
 * @ORM\Column(type="$TYPE$")
 */
private $$$PROPERTYNAME$;

asset

{{ asset('$PATH$') }}

asseticjs

{% javascripts
    '$PATH$'$END$
%}
    <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

asseticcss

{% stylesheets
    '$PATH$'$END$
    filter='cssrewrite'
%}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

xmlservices

Generates an XML services file

<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>
        <service id="$SERVICEID$" class="$CLASS$" />
    </services>
</container>

yamlroute

YAML route

$NAME$:
    path:   /$PATH$
    defaults:  { _controller: $CONTROLLER$ }

querybuilder

Query objects in repositories using query builder

$this->createQueryBuilder('$ALIAS$')
            ->where('$ALIAS$.$PROPERTY$ = :$PARAMETER$')
            ->setParameter('$PARAMETER$', $ARGUMENT$)
            ->getQuery();

trans

Allows fast entering of translated messages

{{ '$MESSAGE$'|trans }}

servix

Creates a XML service

<service id="$NAME$" class="$CLASS$">
    <argument type="service" id="$ARG1$"/>
</service>

Credits

First, a thanks to nicwortel for this https://github.com/nicwortel/phpstorm-ide-config repository, which contains some nice settings (including stuff that we don't have here). He also did a really nice job with his README, and I've borrowed parts of it shamelessly.

A number of people have contributed to this repository. Additionally, some templates were adapted from https://github.com/raulfraile/sublime-symfony2.

phpstorm-settings's People

Contributors

ccab avatar pierstoval avatar pouzor avatar pronskiy avatar roukmoute avatar rwitchell avatar weaverryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpstorm-settings's Issues

Missing context for "createquery"

Hi,

I noticed that createquery shortcode doesn't work.
As a temporary fix I put context tag in <template name="createquery"...

<context>
  <option name="PHP" value="true" />
</context>

Now seems ok.
Did someone else got the same problem?

Cheers :)

Naming files

Hi guys, this project will be awesome ๐Ÿ˜„

What about renaming the different files by prepending knp_ to avoid conflicts for actual configs?
I personally have templates for Symfony inside a symfony.xml file, so having them inside a knp_symfony.xml file would resolve the potential conflicts, and more, allow to unzip the whole project right inside the WebIde** directory.

What do you think about this? :)

Cannot install the Symfony templates

I'm using PHPStorm 2018.1.6 and when I download the files and try to put them in the config dir, the frontend live templates are visible but not the Symfony ones, I can't figure out where is the issue exactly.

Any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.