PhpStorm: Symfony2 Plugin

74
Daniel Espendiller espend.de - [email protected] @Annotation

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

Page 1: PhpStorm: Symfony2 Plugin

Daniel Espendillerespend.de - [email protected]

@Annotation

Page 2: PhpStorm: Symfony2 Plugin

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 - [email protected]

Page 3: PhpStorm: Symfony2 Plugin

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

Roadmap

Page 4: PhpStorm: Symfony2 Plugin

● 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

Page 5: PhpStorm: Symfony2 Plugin

● 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

Page 6: PhpStorm: Symfony2 Plugin

● 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

Page 7: PhpStorm: Symfony2 Plugin

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

Page 8: PhpStorm: Symfony2 Plugin

● 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

Page 9: PhpStorm: Symfony2 Plugin

PsiViewer / PHP Language - Lexer

Page 10: PhpStorm: Symfony2 Plugin

PsiViewer / PHP Language

Page 11: PhpStorm: Symfony2 Plugin

PsiViewer / Twig + Pattern

Page 12: PhpStorm: Symfony2 Plugin

Twig Lexer in PHP?

SymfonyCon Warsaw 2013 - Matthias Noback - Diving Deep Into Twig

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

Page 13: PhpStorm: Symfony2 Plugin

Translations: Array To JavaPHP

Java

Page 14: PhpStorm: Symfony2 Plugin

Plugin Overview

Page 15: PhpStorm: Symfony2 Plugin

Symfony2 Plugin

without Plugin

Page 16: PhpStorm: Symfony2 Plugin

Symfony2 Pluginfr.adrienbrault.idea.symfony2plugin

Page 17: PhpStorm: Symfony2 Plugin

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

Page 18: PhpStorm: Symfony2 Plugin

PHP Annotation

Index

Page 19: PhpStorm: Symfony2 Plugin

PHP AnnotationEntity completion and navigation together with Symfony2 Plugin

Page 20: PhpStorm: Symfony2 Plugin

PHP Annotation

Code > Optimize Imports

Reference between “use” and docblock tag

Page 21: PhpStorm: Symfony2 Plugin

Drupal Symfony2 BridgeRouting, Service Container (Yaml), Twig

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

Page 22: PhpStorm: Symfony2 Plugin

Drupal Symfony2 Bridge

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

Page 23: PhpStorm: Symfony2 Plugin

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

Page 24: PhpStorm: Symfony2 Plugin

Laravel

Page 25: PhpStorm: Symfony2 Plugin

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

Page 26: PhpStorm: Symfony2 Plugin

Shopware

Page 27: PhpStorm: Symfony2 Plugin

… Doctrine ORM QueryBuilder support :)

Shopware\Models\Article\Repository::getArticleQueryBuilder

Shopware

Page 28: PhpStorm: Symfony2 Plugin

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

Page 29: PhpStorm: Symfony2 Plugin

Android Studio PrettifyGenerator: XML Layout to Java

Page 30: PhpStorm: Symfony2 Plugin

Android Studio PrettifyGenerator: XML Layout to Java

Page 31: PhpStorm: Symfony2 Plugin

Android Studio Prettify

Inspection: Cast check of view declaration

Linemarker: View as icon

Page 32: PhpStorm: Symfony2 Plugin

Productivity

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

20.000 Users ...

double your productivity (per month)?

Page 33: PhpStorm: Symfony2 Plugin

Extension Points

Page 34: PhpStorm: Symfony2 Plugin

Extension

<Plugin>/META_INF/plugin.xml

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

Page 35: PhpStorm: Symfony2 Plugin

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

Page 36: PhpStorm: Symfony2 Plugin

ExtensiongotoDeclarationHandler

On demand: ctrl+mousover

Page 37: PhpStorm: Symfony2 Plugin

Extensionpsi.referenceContributor

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

Page 38: PhpStorm: Symfony2 Plugin

● 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

Page 39: PhpStorm: Symfony2 Plugin

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

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

Page 40: PhpStorm: Symfony2 Plugin

ExtensionPhpTypeProvider2

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

Page 41: PhpStorm: Symfony2 Plugin

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

Page 42: PhpStorm: Symfony2 Plugin

Extensionannotator / inspections

Page 43: PhpStorm: Symfony2 Plugin

Extensionlang.foldingBuilder

Reformat string values for better readability

Example in Java: Anonymous class

Page 44: PhpStorm: Symfony2 Plugin

ExtensionlineMarkerProvider

Page 45: PhpStorm: Symfony2 Plugin

Symfony2 Plugin

Page 46: PhpStorm: Symfony2 Plugin

Service ContainerData from appDevDebugProjectContainer.xml, also from FileIndex

Page 47: PhpStorm: Symfony2 Plugin

Service Container

Page 48: PhpStorm: Symfony2 Plugin

Service Container

Page 49: PhpStorm: Symfony2 Plugin

FormFormTypes, Extension (setDefaultOptions)

Page 50: PhpStorm: Symfony2 Plugin

FormDoctrine / Class support

Page 51: PhpStorm: Symfony2 Plugin

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

Page 52: PhpStorm: Symfony2 Plugin

Doctrine

Page 53: PhpStorm: Symfony2 Plugin

DoctrineFind* parameter and QueryBuilder with mapping on Annotation or Yaml

Page 54: PhpStorm: Symfony2 Plugin

Twig

Page 55: PhpStorm: Symfony2 Plugin

Twig

Page 56: PhpStorm: Symfony2 Plugin

Twig

Page 57: PhpStorm: Symfony2 Plugin

TwigForms

Page 58: PhpStorm: Symfony2 Plugin

TwigAssets

Page 59: PhpStorm: Symfony2 Plugin

Twig

Page 60: PhpStorm: Symfony2 Plugin

TwigType docblock

Deprecated: performance

Page 61: PhpStorm: Symfony2 Plugin

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

Page 62: PhpStorm: Symfony2 Plugin

Service Builder

Page 63: PhpStorm: Symfony2 Plugin

Translation Extractor

Page 64: PhpStorm: Symfony2 Plugin

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

Serialized DataCollector -> Regular Expressions :)

Page 65: PhpStorm: Symfony2 Plugin

Symbol Search / Search Everywhere

Navigate -> Symfony2 Symbol...

Page 66: PhpStorm: Symfony2 Plugin

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

Page 67: PhpStorm: Symfony2 Plugin

Server Storage

Page 68: PhpStorm: Symfony2 Plugin

Server Storage

Page 69: PhpStorm: Symfony2 Plugin

Dev Environment / Tools

Page 70: PhpStorm: Symfony2 Plugin

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

Page 71: PhpStorm: Symfony2 Plugin

Dev Environment / ToolsAdd external plugin as library

Page 72: PhpStorm: Symfony2 Plugin

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

externals

Page 73: PhpStorm: Symfony2 Plugin

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

Page 74: PhpStorm: Symfony2 Plugin

Questions?