I am trying to get a local ddev setup working with the stack:
- Apache
- PHP 8.1
- Laravel 9
- Vite
- Soketi for WebSockets
I am confused on how to configure ports on ddev, and which host/port i should use on the frontend.
.ddev/config.yaml
name: laravel-vite-inertia
type: laravel
docroot: public
php_version: "8.1"
webserver_type: apache-fpm
router_http_port: "80"
router_https_port: "443"
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
database:
type: mysql
version: "8.0"
nfs_mount_enabled: false
mutagen_enabled: false
use_dns_when_possible: true
composer_version: "2"
web_environment: []
nodejs_version: "16"
.ddev/docker-compose.vite.yaml
# Override the web container's standard HTTP_EXPOSE and HTTPS_EXPOSE services
# to expose port 3000 of DDEV's web container.
version: '3.6'
services:
web:
# ports are a list of exposed *container* ports
ports:
- "3000"
- "6001:6001"
environment:
- HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:8025,3001:3000
- HTTPS_EXPOSE=${DDEV_ROUTER_HTTPS_PORT}:80,${DDEV_MAILHOG_HTTPS_PORT}:8025,3000:3000
/resources/js/app.js
import Echo from 'laravel-echo';
import pusher from 'pusher-js';
let laravelEcho = new Echo({
broadcaster: 'pusher',
key: 'app-key',
wsHost: '127.0.0.1', // <- I assume this is the error?
wsPort: 6001,
wssPort: 6001,
forceTLS: false,
encrypted: true,
disableStats: true,
enabledTransports: ['ws', 'wss'],
});
laravelEcho.channel(`auctions`)
.listen('AuctionIndexVisited', (e) => {
console.log('AuctionIndexVisited', e);
});
laravel .env
#...
PUSHER_HOST=127.0.0.1
PUSHER_PORT=6001
PUSHER_APP_KEY="app-key"
PUSHER_APP_ID="app-id"
PUSHER_APP_SECRET="app-secret"
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_HOST="${PUSHER_HOST}"
MIX_PUSHER_PORT="${PUSHER_PORT}"
Laravel does broadcasts to soketi.
The frontend is not able to connect to the websocket...