frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Laravel HMR not working

Open ezekel opened this issue 1 year ago • 11 comments

Hi,

I have Laravel + Octane, but the problem the HMR will not work, I need to refresh the page just to reflect the changes.

This is how I access my site in local https://mysite.local

here is my composer

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The skeleton application for the Laravel framework.",
    "keywords": ["laravel", "framework"],
    "license": "MIT",
    "require": {
        "php": "^8.2",
        "laravel/framework": "^11.9",
        "laravel/octane": "^2.5",
        "laravel/sanctum": "^4.0",
        "laravel/tinker": "^2.9"
    },
    "require-dev": {
        "fakerphp/faker": "^1.23",
        "laravel/breeze": "^2.1",
        "laravel/pint": "^1.13",
        "laravel/sail": "^1.26",
        "mockery/mockery": "^1.6",
        "nunomaduro/collision": "^8.0",
        "pestphp/pest": "^2.0",
        "pestphp/pest-plugin-laravel": "^2.0"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi",
            "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
            "@php artisan migrate --graceful --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}


Thank you in advance.

ezekel avatar Aug 11 '24 11:08 ezekel

Did you search existing issues? This looks related: #958

withinboredom avatar Aug 11 '24 12:08 withinboredom

Did you search existing issues? This looks related: #958

The related issue (#958) was from him 😂 I think he just doesn't know how to use Octane and are recreating the issue in frankenphp repo

sneycampos avatar Aug 15 '24 22:08 sneycampos

Hi,

That other thread fixed the API route when I edited the response, and when I use Postman I get the actual response, My problem here is the HMR is not working although I mentioned also in my other thread that the HMR is not working.

ezekel avatar Aug 17 '24 12:08 ezekel

Could you give more details about? Your installation, watcher config etc?

sneycampos avatar Aug 17 '24 13:08 sneycampos

@sneycampos

here is my docker-compose and dockerfile

    php:
        container_name: nuxtnew
        build:
            context: .
            dockerfile: ./docker/web.dockerfile
        image: nuxtnew

        ports:
            - "80:80"
            - "443:443"
            - "443:443/udp" 
            - "5173:5173"
        volumes:
            - .:/app 

        entrypoint: php artisan octane:frankenphp  --watch   --max-requests=250 --host=larabells.local --port=443  --admin-port=2019 --https
        environment:
            - SERVER_NAME=larabells.local
            

In my dockerfile

FROM dunglas/frankenphp:1.2.3-builder-php8.3

RUN install-php-extensions \
    pdo_mysql \
    gd \
    intl \
    zip \
    opcache\
    pcntl\
    @composer


WORKDIR /app

COPY . /app


# Install npm packages
RUN npm install



EXPOSE 5173

ENTRYPOINT ["php", "artisan", "octane:frankenphp", "--watch"]

ezekel avatar Aug 21 '24 10:08 ezekel

@ezekel You need to install chokidar. According to Laravel Octane docs (https://laravel.com/docs/11.x/octane#watching-for-file-changes)

sneycampos avatar Aug 21 '24 11:08 sneycampos

@sneycampos

I already tried installing it inside the container and also to the dockerfile but no luck.

but I can see it to the conainer

 [vite] full reload resources/views/welcome.blade.php
 [vite] full reload resources/views/welcome.blade.php (x2)

ezekel avatar Aug 22 '24 15:08 ezekel

@sneycampos

I already tried installing it inside the container and also to the dockerfile but no luck.

but I can see it to the conainer


 [vite] full reload resources/views/welcome.blade.php

 [vite] full reload resources/views/welcome.blade.php (x2)

This is vite hotreload, you need watcher configured like octane documentation.

sneycampos avatar Aug 22 '24 20:08 sneycampos

Hmmm, I think this is the same issue as me #1293.

Did you ever solved this? I have chokidar installed. The vite refresh works for me on resource files (e.g. vue, js, ts, etc.), but not on php files.

francoism90 avatar Dec 26 '24 14:12 francoism90

We need to send a PR to Octane to switch to the new system.

dunglas avatar Dec 26 '24 19:12 dunglas

@dunglas Ah cool. 😎

francoism90 avatar Dec 26 '24 19:12 francoism90