-
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 kongondo
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:
-
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?
-