Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel HMR not working #965

Open
ezekel opened this issue Aug 11, 2024 · 8 comments
Open

Laravel HMR not working #965

ezekel opened this issue Aug 11, 2024 · 8 comments

Comments

@ezekel
Copy link

ezekel commented Aug 11, 2024

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
Copy link
Collaborator

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

@sneycampos
Copy link
Contributor

sneycampos commented Aug 15, 2024

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
Copy link
Author

ezekel commented Aug 17, 2024

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
Copy link
Contributor

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

@ezekel
Copy link
Author

ezekel commented Aug 21, 2024

@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
Copy link
Contributor

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

@ezekel
Copy link
Author

ezekel commented Aug 22, 2024

@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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants