phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

Navigation to file by functions

Open trollfalgar opened this issue 10 months ago • 4 comments

Hello there!

I would like to suggest navigation to file by Laravel functions like:

asset() secure_asset() public_path() storage_path()

When parameter path is informed.

Also, navigation to files informed in @vite directive.

trollfalgar avatar Jan 08 '25 20:01 trollfalgar

Maybe it's something obvious, but, algo highlight when the file does not exist.

The same when using __DIR__, something like this: image

trollfalgar avatar Jan 08 '25 20:01 trollfalgar

Good point;

How to safely determine the location of directories for

  • asset() - /public/...
  • public_path() - /public/...
  • storage_path() - /storage/...

I can see this is highly configurable, What is the "reasonable" configuration we should check for?

jakubmisek avatar Jan 14 '25 12:01 jakubmisek

Good point;

How to safely determine the location of directories for

  • asset() - /public/...
  • public_path() - /public/...
  • storage_path() - /storage/...

I can see this is highly configurable, What is the "reasonable" configuration we should check for?

@jakubmisek these native Laravel helper functions can be configured, yes.

image

This configuration can be done in bootstrap/app.php.

For Laravel below version 11 (this is the working way for me, in Service Provider doesn't work properly):

image

For Laravel 11 and above:

image

But this configuration can be done for other things, like:

  • useConfigPath()
  • useBootstrapPath()
  • useAppPath()
  • useDatabasePath()
  • useEnvironmentPath()

Basically just look at the bootstrap/app.php file.

Obs: The asset() function just points to the url() method appending the path. I believe it can't be configured.

image

trollfalgar avatar Jan 14 '25 14:01 trollfalgar

Thank you @trollfalgar !

For now, we'll use the default values; if they don't exist, we won't suggest anything.

In the next update, we'll try to be smarter about the paths.

jakubmisek avatar Jan 14 '25 15:01 jakubmisek