dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.66k stars 219 forks source link

Laravel HMR not working #965

Open ezekel opened 1 month ago

ezekel commented 1 month ago

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.

withinboredom commented 1 month ago

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

sneycampos commented 3 weeks ago

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

ezekel commented 3 weeks ago

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.

sneycampos commented 3 weeks ago

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

ezekel commented 3 weeks ago

@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"]
sneycampos commented 3 weeks ago

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

ezekel commented 2 weeks ago

@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)
sneycampos commented 2 weeks ago

@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.