Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later

1,094 views

Published on

In 2013 the "Symfony Plugin" for PhpStorm was born. Today we see over 1 million downloads and several other plugins for projects like Laravel, Drupal, Shopware, ... that help to improve your productivity.

I will talk about Symfony related features and will give you some tips and tricks. Also, we take a look at the infrastructure behind these plugins and how I maintain all of them.

Published in: Software
  • ♣♣ 10 Easy Ways to Improve Your Performance in Bed... ▲▲▲ https://tinyurl.com/rockhardxxx
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later

  1. 1. PhpStorm + Symfony SymfonyCon 2016 - Daniel Espendiller - @BigHaehnchen
  2. 2. Symfony Plugin PHP Annotations Shopware Plugin Drupal Symfony Bridge Laravel Plugin OXID Plugin PHP Toolbox Plugins Daniel Espendiller E-Mail: daniel@espendiller.net Twitter: @BigHaehnchen GitHub: //github.com/Haehnchen
  3. 3. Roadmap ● Problems / Statistics / Infrastructure – Key Facets, Statistics, Travis, JetBrains API ● Features – Symfony Installer, Service and Container, Form, Events, Doctrine, Code Generator, Twig Doc, Twig Namespaces, Translations, Profiler, Remote Container, PHP-Toolbox
  4. 4. First commits (2013/04)
  5. 5. Key Facets (since 2013/04) ● 7 Plugins ● ~2,5 Mio Downloads ● ~1.000 Issues ● ~50.000 LOC (Java) ● Time Investment: ~4h weekly ● Single person project ● MIT License ● Framework like, feel free to copy https://github.com/Haehnchen/idea-*
  6. 6. Symfony Plugin Update
  7. 7. Symfony Plugin / Contribution
  8. 8. Testing / Travis
  9. 9. public class XmlDicCompletionContributorTest extends SymfonyLightCodeInsightFixtureTestCase { public void setUp() throws Exception { super.setUp(); myFixture.copyFileToProject("appDevDebugProjectContainer.xml"); myFixture.configureByText("classes.php", "<?phpn" + "namespace FooName;n" + "class FooClass {" + " public function foo() " + "}" ); } public void testServiceCompletion() { assertCompletionContains("service.xml", "<?xml version="1.0" encoding="utf-8"?>n" + "<container>n" + " <services>n" + " <argument type="service" id="<caret>"/>n" + " </services>n" + "</container>" , "data_collector.router" ); } } Testing / Travis sry Java Code
  10. 10. JetBrains API PsiViewer Yaml File
  11. 11. “There are to be some PSI structure changes; I see that your plugin use YAML extensively so something will definitely break. To be honest, I wanted to do some changes which may even break compilation, but I can leave some legacy code. However, one will need to fix the usage of PSI so I don't think it's a big problem.” JetBrains API
  12. 12. “There is a patch to master which compiles but leads to about 60 tests failing. However, you can look through the changes to have an idea of what's happening.” JetBrains API
  13. 13. JetBrains API Yaml: [@service, "@service2", [""], ['']]
  14. 14. JetBrains API / 2016.3 PhpStorm 2016.3 EAP 163.5644 / Initial PHPSpec support
  15. 15. Features Symfony Installer Service and Container Form Events Doctrine Code Generator Twig Doc Twig Namespaces Translations Profiler Remote Container PHP-Toolbox
  16. 16. Symfony Installer File → New Project → Symfony
  17. 17. Symfony Installer File → New Project → Symfony
  18. 18. Container <?php namespace espendContainerServiceBundleClasses; use SymfonyComponentRoutingRouterInterface; class Bar extends Twig_Extension { public function __construct(RouterInterface $router) { } public function getName() { } } Class Template
  19. 19. Container Service Generator
  20. 20. Container Service Generator
  21. 21. Container Javascript: Service Id Strategy
  22. 22. Container Autocompletion
  23. 23. Container Argument Detection
  24. 24. Form Option Completion and Navigation
  25. 25. Form Option Completion and Navigation
  26. 26. Form public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('test', 'birthday'); $builder->add('test', 'file'); $builder->add('test', 'file'); } public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('test', BirthdayType::class); $builder->add('test', FileType::class); $builder->add('test', FileType::class); } Symfony 3.x Migration
  27. 27. Form Symfony 3.x Migration: Generator / Inspection
  28. 28. Events use SymfonyComponentHttpKernelEventFilterControllerEvent; public function onKernelController(FilterControllerEvent $event) { } Method Generation
  29. 29. Events final class KernelEvents { /** * @Event("SymfonyComponentHttpKernelEventFilterControllerEvent") */ const CONTROLLER = 'kernel.controller'; } * * This event allows you to change the controller that will handle the * request. The event listener method receives a * SymfonyComponentHttpKernelEventFilterControllerEvent instance. * * @var string * * @api */ const CONTROLLER = 'kernel.controller'; Symfony Event Definition
  30. 30. Doctrine namespace Bar; class FooBar { private $id; private $createdAt; private $isActive; } namespace Bar; use DoctrineORMMapping as ORM; class FooBar { /** * @ORMId * @ORMGeneratedValue(strategy="AUTO") * @ORMColumn(type="integer") */private $id; /** * @ORMColumn(type="datetime") */ private $createdAt; /** * @ORMColumn(type="boolean") */ private $isActive; } Annotation Generator
  31. 31. Doctrine Metadata - XML
  32. 32. Doctrine Metadata - Annotation
  33. 33. Generator File - Template
  34. 34. Generator Method - Route class DefaultController extends Controller { public function fooAction() { } }
  35. 35. Generator Event Method class YamlClass { public function onFoobar(GetResponseForExceptionEvent $event) { } }
  36. 36. Twig Doc {# @var cars espend[...]EntityCar #} {# @var cars espend[...]EntityCar[] #} {# @controller AcmeDemoBundle:Demo:hello #} {# @see test.html #}
  37. 37. Twig Doc (var)
  38. 38. Twig Doc (var)
  39. 39. Twig Doc (controller) public function indexAction() { $this->render('index.html.twig'); $this->renderView('index.html.twig'); $this->renderResponse('index.html.twig'); }
  40. 40. Twig Doc (controller) public function indexAction() { return ['foo_request' => new Request()]; return $this->render(null, ['foo_request_render' => new Request()]); }
  41. 41. Twig Doc (see) {# @see foo/foo.html.twig #} {# @see @WebProfiler/Profiler/table.html.twig #} {# @see ../root.html.twig #} {# @see ../root.json #} {# @see espendRouterRoutesBundle:Default:index #} {# @see web_profiler.controller.profiler:searchBarAction #} {# @see espendRouterRoutesBundleControllerDefaultController #} {# @see [...]DefaultController::indexAction #} Twig Templates Filesystem Classes Routes
  42. 42. Twig Namespace File → Settings → … → Symfony → Twig / Templates
  43. 43. Twig Namespace File → Settings → … → Symfony → Twig / Templates # ide-twig.json { "namespaces": [ { "namespace": "foo", // @foo/foobar.html.twig "path": "res" }, { "path": "res" // foobar.html.twig }, { "path": "res", // FooBundle::foobar.html.twig "type": "Bundle", "namespace": "FooBundle" } ] }
  44. 44. Translations Extraction
  45. 45. Translations Extraction
  46. 46. Translations XLIFF Support
  47. 47. Profiler Language & Frameworks → Symfony → Profiler
  48. 48. Remote Container appDevDebugProjectContainer.xml Tools → Deplyoment → Configuration
  49. 49. Remote Container appDevDebugProjectContainer.xml
  50. 50. PHP-Toolbox https://github.com/Haehnchen/idea-php-toolbox
  51. 51. PHP-Toolbox // .ide-toolbox.metadata.json { "registrar":[ {"language":"php", "provider":"MY_FOO", "signature": ["Foo:bar"]}, {"language":"twig", "provider":"MY_FOO", "signatures":[{"function": "foo"}]} ], "providers": [ { "name": "MY_FOO", "items":[ { "lookup_string": "POST", "icon": "com.jetbrains.php.PhpIcons.PROFILER_SNAPSHOT_FILE_TYPE" }, { "lookup_string": "GET" }, { "lookup_string": "DELETE", "type_text": "Sweet Stuff" } ] } ] }
  52. 52. PHP-Toolbox // .ide-toolbox.metadata.json { "registrar":[ { "provider":"FOOBAR", "language":"php", "signatures":[{"class": "Foo", "method": "bar", "type": "type"}] } ], "providers": [ { "name": "FOOBAR", "items":[ { "lookup_string": "foobar", "type": "DateTime" } ] } ] }
  53. 53. PHP-Toolbox [GET] / [GET] /projects [GET] /projects/{project} [GET] /projects/{project}/clear [POST] /projects/{project}/{provider} [GET] /projects/{project}/json-debug Languages & Frameworks -> PHP Toolbox curl -X POST http://127.0.0.1:48734/projects/idea-espend/php-toolbox-json -d @test.json { "success": true, "content": "items added" }
  54. 54. Questions Feedback ...

×