donnikitos / vite-plugin-php

Vite's speed and tooling to preprocess PHP-files!
https://www.npmjs.com/package/vite-plugin-php
MIT License
25 stars 0 forks source link

Loading autoloader from vendor folder seems to interfere in dev server #5

Open skabeche opened 8 months ago

skabeche commented 8 months ago

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.

donnikitos commented 8 months ago

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?

skabeche commented 8 months ago

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"
    }