[Twig] Global PhpTypes for all files
See original GitHub issueI would like to see a way to define global PhpTypes for my entire project.
I’m using Craft CMS so there is no real way to access the Twig config without overwriting things and I would like to define
{# @var variable_name \Foo\Bar #}
only once and use this variable in all templates. Currently the first line of all my templates is {# @var craft \Craft\CraftVariable #} it would be better to type that only once somewhere and use it everywhere.
Is there a way to do this?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to Inject Variables Automatically into all Templates
Twig allows you to automatically inject one or more variables into all templates. These global variables are defined in the twig.globals option inside...
Read more >service method as twig global variable - php - Stack Overflow
Use it a Twig file ... One approach is use a CONTROLLER event listener. I like to use CONTROLLER instead of REQUEST because...
Read more >Twig - SlideShare
This is the documentation for Twig, the flexible, fast, and secure template engine for PHP. Viewed by www.thanh.ch.
Read more >En.json
Users can also String data by uploading the file. A specification for building APIs in JSON. The editor offers all your need in...
Read more >How to Inject Variables into all Templates (i.e. global Variables)
This is possible inside your app/config/config.yml file: YAML. # app/config/config.yml twig: # ... globals: ga_tracking: UA-xxxxx-x.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Formalized this in the Auto-Complete Craft CMS 3 APIs in Twig with PhpStorm article
Thank you so much, this is perfect 😄 Guten Rutsch in das neue Jahr 😛