donnikitos/vite-plugin-php

Loading autoloader from vendor folder seems to interfere in dev server

Closed this issue · 4 comments

System:
Linux Mint 21.2
LAMP server with Lando based in Docker.
PHP 8.1
Vite v4.5.0
Node v18.17.1

Running dev server

npm run dev

Loading autoloader from vendor folder:

/**
 * Autoloader.
 */
require_once __DIR__ . '/../vendor/autoload.php';

The page keeps reloading and never stops, so the page never appears to reflect changes.
I guess the plugin tries to escape this folder too, is there any way to ignore it?

The production build works fine though.

Technically the plugin only escapes the PHP code in the files, that you define in the configuration. So in theory that shouldn't affect the autoloader.
Can you show me, how you define the

/**
 * Autoloader.
 */
require_once __DIR__ . '/../vendor/autoload.php';

part in your file?

Sorry for the late reply.
Although this is not exactly how it is implemented in my system, you can test it as follows:

<?php require_once __DIR__ . '/../vendor/autoload.php'; ?> 
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Test</title>
</head>
<body>
  <p>Test</p>
</body>
</html>

It keeps loading forever.

These are my packages in composer.json

    "require-dev": {
        "kint-php/kint": "^5.0",
        "phpunit/phpunit": "^10.4"
    },
    "require": {
        "symfony/yaml": "^6.3",
        "vlucas/phpdotenv": "^5.5",
        "guzzlehttp/guzzle": "^7.7",
        "phpfastcache/phpfastcache": "^9.1"
    }

Hi @skabeche,
quite a few updates later already. At the current stage I am not able to reproduce it.
Wanted to double check if this issue does still persist on your end?

Cheers

Hi @donnikitos
Thanks for taking a look.
I'm afraid it's been a while since this issue and I can not test it again as the project no longer uses this plugin.
Thanks for your efforts and the good work with this plugin. We may close this ticket.