Intellisense on path when using defined constants


In my projects I am using a config file where I define constants based off whether I am working locally or remotely.

if ($local) {
    // Define the constants:
    define ('BASE_URL', '');
    define ('BASE_URL', '');

In my code I use something like this to define the location of a src.

<img src="<?php echo BASE_URL; ?>images/image.jpg" />

This works really well, in the sense that local & remote paths are instantly correct. However I lose intellisense when typing out URL's

What is the best solution? Should I be using a URI type path?

Can I set up multiple 'Resource Roots' on a single project and the intellisense will look in these folders too?

Thanks Community!


Thank you for the reply.

I also have some other constants defined such as BASE_CSS. Will this method work if you want to have multiple bases defined?

I guess just defining the one base tag is still good, no real need to define constants for CSS, JS, IMAGES & BASE_URL.

I will give this a go at work tomorrow.



Please sign in to leave a comment.