Jump to content

Visual Studio Code for ProcessWire Developers

Recommended Posts

1 hour ago, bernhard said:

Do you guys have a recommendation how to sort method names of a class by their name alphabetically? Thx

If the methods are still empty as in your example or populated?

Share this post

Link to post
Share on other sites
2 hours ago, bernhard said:

Good point! Populated 🙂 

No idea then, in that case, sorry 😄 

  • Haha 1

Share this post

Link to post
Share on other sites

Another question: Any ideas how I can transform this:


into that:


? 🙂 

Share this post

Link to post
Share on other sites

Tip: Giving Folders Custom Display Names

I created a workspace where I wanted to add the "site" folder from various ProcessWire sites that I'm working on to do some updates across all the projects, as opposed to opening each workspace independently, one after another.

VSCode can handle this, however because the folder name is always "site", it's impossible to differentiate which "site" folder belongs to which project in the sidebar.

But, there's a way to set up a custom name override which I thought was very useful.  Simply edit the .code-workspace file and add a "name" property to each root folder, so it looks like this:

	"folders": [
			"path": "."
			"name": "website 1 /site/",
			"path": "../website-1.com/site/"
			"name": "website 2 /site/",
			"path": "../website-2.com/site/"

While I could have added "website-1.com" and "website-2.com" which would have resulted in unique folder names anyway, my specific use case was a bit more involved than what I demonstrated above, so hopefully you find this tip helpful!

Link: https://github.com/Microsoft/vscode/issues/45227#issuecomment-371380617

  • Like 4

Share this post

Link to post
Share on other sites

I've just switched to using PHP Intelephense in VSCode which is definitely a step up from the old PHP IntelliSense module.

One issue I have now though is because I generally don't keep core PW files in my projects then Intelephense is showing lots 'undefined method' errors:


I've tried pointing the Intelephense stubs settings at a folder containing a copy of the core PW files which kind of works but doesn't seem to pull in module methods (as in that screenshot).

I can add methods indiviudally to a stubs file so I've got most of the methods covered but does anyone have a complete stubs file or is there some other better solution?

Share this post

Link to post
Share on other sites

  • 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.
      Install the Auto Template Stubs module.
      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.
      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.
    • 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.
      "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?
  • Create New...