Jump to content

Visual Studio Code for ProcessWire Developers


kongondo

Recommended Posts

Visual Studio Code for PW Devs

This thread is a place for ProcessWire developers who use Visual Studio Code (aka VSC or Code)  to share their experience, tips, frustrations , solutions, code snippets and generally discuss all things VSC.

From Wikipedia:

Quote

Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.

 

  • Like 8
Link to comment
Share on other sites

@adrian,

Yes, the PHP IntelliSense is not the best. What extension are you using? This PHP IntelliSense one? That's the one I use. I have never had any luck with auto-completion for PW. Seems you are doing better than me. I suppose the reason is that I don't have the wire folder included as a source in my projects. Are you including wire? Maybe with the new-ish Multi-root workspace implementation I should be able to add wire in my projects in order to get to at least where you are. I'll have a play with this and post back.

Whenever I get the time, I will also post tips and tricks I've gathered so far.

 

Edited by kongondo
  • Like 1
Link to comment
Share on other sites

2 hours ago, FrancisChung said:

If it's any consolation, it's not that great in PHPStorm either. I think I will setup a similar forum topic for PHPStorm users to vent their frustrations and workarounds.

You PHP Intellisense for PW isn't great or PHP Intellisense in General because I use it for Symfony and Yii2 and it's superb but a memory hogger. Netbeans still tops it all in terms of speed for me. 

  • Like 1
Link to comment
Share on other sites

2 hours ago, Ivan Gretsky said:

This issue is what primarily stops me from using VS Code for php development (and that means "at all").

Ivan, what exactly? HTML IntelliSense? The extensions I use provide HTML auto-completion, tag matching (and changing) and CSS IntelliSense. I'll post my list of extensions later.

  • Like 1
Link to comment
Share on other sites

27 minutes ago, kongondo said:

Ivan, what exactly? HTML IntelliSense? The extensions I use provide HTML auto-completion, tag matching (and changing) and CSS IntelliSense. I'll post my list of extensions later.

It is html, css and js in php files. IntelliSense (at least out of the box) just does not recognize that it is html context embedded in php PW template, so no autocompletion and stuff. Felix Becker (the creator of php language server, used in VS Code as the base for php IntelliSense) writes about it in the mentioned issue.

I did not find a workaround.

Edit: Actually the main problem is the other way around. PHP includes in html templates/views.

  • Like 1
Link to comment
Share on other sites

This topic made me check the progress on Atom IDE project. The 1.21 version of atom is finally out of beta, so now one can install it without switching to beta channel. Atom IDE uses the same Felix Becker's language server, and has language contexts figured out, as far as I know. While at it upgraded my Windows Atom to x64 version (startup appeared to be a little faster, but maybe I'm just dreaming). Jump to class definition works. Auto-completion works, Outline view is present.

Somehow I consider Atom to be more open source and open in general than VS Code. So will try stick to it for now. VS Code starts up a bit faster, but they have near feature parity now. Good competition is good!

Link to comment
Share on other sites

2 hours ago, Ivan Gretsky said:

Felix Becker (the creator of php language server, used in VS Code as the base for php IntelliSense) writes about it in the mentioned issue.

Hmm. Felix is the author and maintainer of the PHP IntelliSense extension I referred to. I do not use the VSC code in-built one.

 

52 minutes ago, Ivan Gretsky said:

Jump to class definition works. Auto-completion works

Works for me too in VSC.

IntelliSense

I have noticed that if I do this:

$animals = new Animals();
$traits = $animals->getTraits();

PHP IntelliSense works fine. However, if I do this...

public $animals
$this->animals = new Animals();
$traits = $this->animals->getTraits();

It doesn't work...I have been meaning to file a 'bug' report.

I've tried the other IntelliSense but they don't work as well as Felix's. 

Edited by kongondo
  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
1 hour ago, elabx said:

Does anyone know if you can edit a remote location ftp/ssh, and navigate it as a file system??

In my emacs setup this is so straightforward but I never found a way to do this in VS Code. 

https://codepen.io/ginfuru/post/remote-editing-files-with-ssh

https://marketplace.visualstudio.com/items?itemName=rafaelmaiolla.remote-vscode

Nothing here in the Marketplace?

Link to comment
Share on other sites

That just feels a bit too impractical, because they  involve ssh tunneling and open a single file, out of the vscode interface. I think I found what I'm looking for but it's not released yet: 

https://code.visualstudio.com/updates/v1_17#_preview-remote-file-system-api

This let's you navigate the remote server as if it was local. 

 

 

  • Like 1
Link to comment
Share on other sites

I'm using this one: https://marketplace.visualstudio.com/items?itemName=lukasz-wronski.ftp-sync

I'm not 100% happy but it works most of the time. Searching through all files only works when you have all files on your computer. This ftp sync sucks for that part. I always zip everything and download it... much faster most of the time. Maybe the new duplicator module could help here...

Another thing that I do is browsing the server over ssh via winscp and then just doubleclick the file. This opens the file on VSCode and on save uploads the new version.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
1 hour ago, bernhard said:

ps: i don't want to abuse this thread for interesting stuff about vscode that is not related to processwire if that is not wanted...?

This is dev talk, so why not....? You are good.

Quote

Dev Talk

A place for general development and coding discussions.

 

Link to comment
Share on other sites

  • 3 weeks later...
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      This module is inspired by and similar to the Template Stubs module. The author of that module has not been active in the PW community for several years now and parts of the code for that module didn't make sense to me, so I decided to create my own module. Auto Template Stubs has only been tested with PhpStorm because that is the IDE that I use.
      Auto Template Stubs
      Automatically creates stub files for templates when fields or fieldgroups are saved.
      Stub files are useful if you are using an IDE (e.g. PhpStorm) that provides code assistance - the stub files let the IDE know what fields exist in each template and what data type each field returns. Depending on your IDE's features you get benefits such as code completion for field names as you type, type inference, inspection, documentation, etc.
      Installation
      Install the Auto Template Stubs module.
      Configuration
      You can change the class name prefix setting in the module config if you like. It's good to use a class name prefix because it reduces the chance that the class name will clash with an existing class name.
      The directory path used to store the stub files is configurable.
      There is a checkbox to manually trigger the regeneration of all stub files if needed.
      Usage
      Add a line near the top of each of your template files to tell your IDE what stub class name to associate with the $page variable within the template file. For example, with the default class name prefix you would add the following line at the top of the home.php template file:
      /** @var tpl_home $page */ Now enjoy code completion, etc, in your IDE.

      Adding data types for non-core Fieldtype modules
      The module includes the data types returned by all the core Fieldtype modules. If you want to add data types returned by one or more non-core Fieldtype modules then you can hook the AutoTemplateStubs::getReturnTypes() method. For example, in /site/ready.php:
      // Add data types for some non-core Fieldtype modules $wire->addHookAfter('AutoTemplateStubs::getReturnTypes', function(HookEvent $event) { $extra_types = [ 'FieldtypeDecimal' => 'string', 'FieldtypeLeafletMapMarker' => 'LeafletMapMarker', 'FieldtypeRepeaterMatrix' => 'RepeaterMatrixPageArray', 'FieldtypeTable' => 'TableRows', ]; $event->return = $event->return + $extra_types; }); Credits
      Inspired by and much credit to the Template Stubs module by mindplay.dk.
       
      https://github.com/Toutouwai/AutoTemplateStubs
      https://modules.processwire.com/modules/auto-template-stubs/
    • By FrancisChung
      PHPStorm for PW Devs
      This thread is a place for ProcessWire developers who use PHPStorm to share their experience, tips, frustrations, solutions, code snippets and generally discuss all things PHPStorm.
      From Wikipedia:
       
      Thanks @kongondo for the Visual Studio Code post earlier.
    • By szabesz
      CodeRunner 2 is on sale at MacUpdate: https://www.macupdate.com/app/mac/38362/coderunner
      Mostly I use it for writing shell scripts, mocking up algorithms in PHP, JavaScript/jQuery. But is also supports other programming languages as well.
      https://coderunnerapp.com/
      "An advanced, highly flexible, and easy-to-use programming editor for your Mac. CodeRunner supports a large number of languages, and delivers big IDE features while remaining lightweight and clutter-free."
    • By pwFoo
      I moved from netbeans to atom. Tested lighttable, brackets and visual studio code, but at the moment I take a look into web based IDEs. Most are based on ACE editor (alternative could be codemirror) like chrome apps caret or super neutron drive (both with chrome dependency at the moment). 
      Recently I looked into cloud9, codetasty, ... and codiad.
      Codiad is open source. php / js based and works fine. Autocomplete feature and suggestions should be improved, but it's ok. Because it's open source you can download it from github repo or test it as a docker container (wernight/codiad image for example). 
      Codytasty is a cloud hosted solution with a really awesome autocomplete / suggestions for php, js and html! But it isn't open source (there is a free to use hosted version with limited workspaces and features).
      At the moment I testing codiad@docker, but use still atom for coding and searching for the best IDE out there *g*
       
      What do you think about IDEs and the new trend to web based IDEs?
    • By benbyf
      HELLO! Anyone happen to be using Atom the open source IDE from github? I've been using it for about a year now and other than the occassional crash it's been great.
      I was wondering if anyone out there has proccesswire specific snippets, syntax hightlighting or autocomplete package they've created to add their PW work? If not would anyone be interested if I made one, and what would be most useful?
×
×
  • Create New...