PhpStorm: Symfony2 Plugin

Post on 14-Jun-2015

1.220 views 2 download

Tags:

description

Some infomation about PhpStorm and IntelliJ development on the plugins: Symfony2 Plugin, Annotation, Shopware, Laravel and Drupal. Also some extension points analysis of IntelliJ and PhpStorm ------------- SymfonyLive Berlin 2014

Transcript of PhpStorm: Symfony2 Plugin

Daniel Espendillerespend.de - daniel@espendiller.net

@Annotation

Symfony2 Plugin2013-03 - Downloads: ~900.000 - daily usage: 20.000 – 40.000

PHP Annotations2013-09 - daily usage: ~15.000

Laravel Plugin2014-08 - daily usage: 1.000-2.000

Shopware Plugin2014-02 - daily usage: ~1.000

Drupal Symfony2 Bridge2014-06 - daily usage: ~500

Android Studio Prettify

Not working for them :) Daniel Espendillerespend.de - daniel@espendiller.net

● About PhpStorm / IntelliJ● IntelliJ: Java Lexer / Pattern● IntelliJ: Extension Points● PhpStorm Plugin Overview● Symfony2 Plugin (all Features :))● Dev Enviroment, Tools, Resources● Questions

Roadmap

● PhpStorm based on IntelliJ IDEA (Java)– With plugins: PHP, Twig, Yaml, …

● „PhpStorm 1.0 & WebStorm 1.0 are public, it is official!“– May 27, 2010

● PhpStorm 5: Symfony2 Framework Integration :(– September 12, 2012– Closed source, so no public API

● PhpStorm6: PHP OpenApi– March 12, 2013

PhpStorm / IntelliJ

● PhpTypeProvider2 (ContainerInterface::get)– PhpTypeProvider(1) freeze not usable

– Magento Plugin, Adrien Brault and PhpStorm Core Developer

– Help on debug

– What do we need and how do we use it?

– More user feedback from real life projects; only on Symfony2 Plugin

– Time issue for release date● Twig as separate plugin (before: inside PHP)● PhpStorm 7.0

– Improved PhpDoc support (Annotations)● PhpStorm 7.1:

– Dev in sync with IntelliJ IDEA

PhpStorm / IntelliJ

● IntelliJ / PhpStorm doc and code examples– Decompile and try on your own :)

● API, stopHere :)● Single person project(s)● My project(s) time window: ~4 hours per week● Better JetBrains support, because of your downloads

– Faster API updates– Pls update to PhpStrom8; only 35%

PhpStorm / IntelliJ

IntelliJ IDEAJava, Lexer, Pattern, PsiElement, ...

● No PHP interpreter all magic in Java● Closed Source for Plugins (PHP, Twig, Yaml, ...)● Open-Source IntelliJ Community Edition● Display document structure (Lexer output) with Plugin: PsiViewer

● Code wrapped into PsiElements, which are targets for all extensions

● Just references [MethodReference → resolve() → Method()]

PsiViewer: https://plugins.jetbrains.com/plugin/227

PhpStorm / IntelliJ IDEA

PsiViewer / PHP Language - Lexer

PsiViewer / PHP Language

PsiViewer / Twig + Pattern

Twig Lexer in PHP?

SymfonyCon Warsaw 2013 - Matthias Noback - Diving Deep Into Twig

http://www.youtube.com/watch?v=jDM0u0B_tXo

Translations: Array To JavaPHP

Java

Plugin Overview

Symfony2 Plugin

without Plugin

Symfony2 Pluginfr.adrienbrault.idea.symfony2plugin

2013

-04

2013

-05

2013

-06

2013

-07

2013

-08

2013

-09

2013

-10

2013

-11

2013

-12

2014

-01

2014

-02

2014

-03

2014

-04

2014

-05

2014

-06

2014

-07

2014

-08

2014

-09

0

10000

20000

30000

40000

50000

60000

70000

80000

90000

100000

Symonfy2 - PhpStorm PluginDownloads Per Month

Symfony2 Plugin

PHP Annotation

Index

PHP AnnotationEntity completion and navigation together with Symfony2 Plugin

PHP Annotation

Code > Optimize Imports

Reference between “use” and docblock tag

Drupal Symfony2 BridgeRouting, Service Container (Yaml), Twig

modules/<module>/<module>.services.info.yml

Drupal Symfony2 Bridge

modules/<module>/<module>.info.yml

Laravel- Better Blade (Template) support of PhpStorm8: Linemaker, include, overwrites, …- (Symfony2) Translations- (Symfony2) Config- ...

Laravel

Shopware- Subscriber (Enlight): events, hooks and proxy classes- Template: Smarty- Doctrine for database

Shopware

… Doctrine ORM QueryBuilder support :)

Shopware\Models\Article\Repository::getArticleQueryBuilder

Shopware

Android Studio PrettifyGoogle Android team is switching to IntelliJ IDEA (Android Studio)

Google I/O 2013 - What's New in Android Developer ToolsGoogle I/O 2014 - What's new in Android development tools

Android Studio PrettifyGenerator: XML Layout to Java

Android Studio PrettifyGenerator: XML Layout to Java

Android Studio Prettify

Inspection: Cast check of view declaration

Linemarker: View as icon

Productivity

1 User * 6 hours per day * 20 days = 120 hours

20.000 Users ...

double your productivity (per month)?

Extension Points

Extension

<Plugin>/META_INF/plugin.xml

http://confluence.jetbrains.com/display/IntelliJIDEA/Custom+Language+Support

Extension:completion.contributor

On demand: ctrl+space or in our custom auto popup (completion.confidence)

Tip: Press „Tab“ for element selection; matches underlying string

Twig hack :)

Lookup stringType text

Tail text

ExtensiongotoDeclarationHandler

On demand: ctrl+mousover

Extensionpsi.referenceContributor

● Can provide completion (deprecated) and navigation● Live event: On file change, inspection, reference search ...● „Php Annotation“: references between „use“ and „Annotation“● >30ms

● Primary extension of IntelliJ IDEA (“Invalidate Caches / Restart”)● Application storage (not per Project!) for strings● Storage structure: File -> Key -> Values[] ● File change listener● Background job, switching to „block mode“ on mass changes (project initialize)● Only lexer output

Extension - fileBasedIndex

<- Class index

Extension - fileBasedIndexPath: %HOMEPATH%/WebIde80/system/index

On Symfony2 PluginReplacement for appDevDebugProjectContainer.xml: - Services: Definition, Parameter, Tags - Twig usage for extends, include, macros, … - Translations - Routes - ...

ExtensionPhpTypeProvider2

● Adds types (Classes, Interface) to methods, variables, … (the yellow ones)● Signature modification: Append string parameter for higher application level

ExtensionPhpTypeProvider2

Signature#Ő#M#P#C\espend\Doctrine\ModelBundle\Controller\DefaultController.container.getƀtwig

X - coreX - our changes: special utf-8 char to split and get „twig“ parameter

Extensionannotator / inspections

Extensionlang.foldingBuilder

Reformat string values for better readability

Example in Java: Anonymous class

ExtensionlineMarkerProvider

Symfony2 Plugin

Service ContainerData from appDevDebugProjectContainer.xml, also from FileIndex

Service Container

Service Container

FormFormTypes, Extension (setDefaultOptions)

FormDoctrine / Class support

FormTranslations: FileIndex or app/cache/dev/translations/catalogue.*.php

Doctrine

DoctrineFind* parameter and QueryBuilder with mapping on Annotation or Yaml

Twig

Twig

Twig

TwigForms

TwigAssets

Twig

TwigType docblock

Deprecated: performance

„Template Create“ Quickfixwith „extends“ and „block“ context search

Service Builder

Translation Extractor

Profilerapp/cache/dev/profiler/index.csv3f318b,127.0.0.1,GET,http://127.0.0.1:8000/hello/test,1414590230,

Serialized DataCollector -> Regular Expressions :)

Symbol Search / Search Everywhere

Navigate -> Symfony2 Symbol...

Server Storage?

http://127.0.0.1:22221/projecthttp://127.0.0.1:22221/project/idea-espendhttp://127.0.0.1:22221/project/idea-espend/clear

Vagrant, VMs, Sync, Remote for „app/cache“ Folder.Other Frameworks: Zend, Typo3 / Flow, “external” Doctrine, Silex, ...

JSONHTTP

http://*:22221

PHP Example: https://github.com/Haehnchen/ide-tools

Server Storage

Server Storage

Dev Environment / Tools

JetBrains\PhpStorm 8.0.1\plugins\php\lib\php.jarJetBrains\PhpStorm 8.0.1\plugins\php\lib\php-openapi.jarJetBrains\PhpStorm 8.0.1\plugins\twig\lib\twig.jar

Java Decompiler: JD-GUI - http://jd.benow.ca/

Dev Environment / Tools

Dev Environment / ToolsAdd external plugin as library

Dev Environment / ToolsDecompile PHP plugin and add sourcepath, to get source code support for

externals

Dev Environment / Tools

● idea-php-symfony2-plugin-test● github: idea-*● Wissenwertes über die IntelliJ IDEA / PhpStorm Plugin Entwicklung● JetBrains: JetBrains: Custom Language Support● Doc: symfony2-plugin.espend.de● JetBrains: Symfony Development using PhpStorm● JetBrains: Drupal Development using PhpStorm

Questions?