README

1. 安装

routes/web.php 中移除欢迎路由。

将以下内容添加到您的 config/filesystem.php 配置文件中

    'links' => [
        ...
        public_path('flux') => base_path('vendor/team-nifty-gmbh/flux-erp/public'),
    ],

链接 flux-erp 资产

php artisan storage:link

这将创建一个指向 public/flux 的符号链接到 vendor/team-nifty-gmbh/flux/public,这是 flux-erp 资产存储的位置。

如果您想使用种子文件,请将以下内容添加到您的 DatabaseSeeder.php 文件中

$this->call(\FluxErp\Database\Seeders\FluxSeeder::class);

因为 vite 将推送数据包含在构建过程中,所以在安装后需要重新构建资产。

vite build

请记住,在设置 .env 文件中的推送者凭证后执行此操作。

2. 开发

如果您想为 flux-erp 开发,应发布 docker 文件(这使用 nginx 而不是 artisan serve)

php artisan vendor:publish --tag="flux-docker"

作为替代方案,您可以更改您的 docker-compose.yml 文件以使用来自 vendor 文件夹的 flux-erp docker 文件。

    laravel.test:
        build:
            context: ./vendor/team-nifty-gmbh/flux-erp/docker/8.2 # <--- Here
   ...

如果您已经构建了 docker 镜像,您应该重新构建它们

sail build --no-cache

3. 运行测试

cd vendor/flux-erp
composer i
composer test

2. Websockets

我期望您使用 nginx 和 certbot ssl 运行 flux 应用程序。重要的是要理解 nginx 作为运行在 supervisor 中的 websockets 的代理。

这意味着您的 supervisor 配置文件应使用与 nginx 配置文件中不同的端口。您应使用端口 443 构建Pusher配置,因为它应该是您的应用程序的生产端口。

// resources/js/bootstrap.js
import Echo from 'laravel-echo'
import Pusher from 'pusher-js';

window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: import.meta.env.VITE_PUSHER_APP_KEY,
    cluster:import.meta.env.VITE_PUSHER_APP_CLUSTER,
    wsHost: window.location.hostname, // <-- important if you dont build the js file on the prod server
    wsPort: 80, // <-- this ensures that nginx will receive the request
    wssPort: 443, // <-- this ensures that nginx will receive the request
    disableStats: true,
    enabledTransports: ['ws', 'wss'],
});

您的 nginx 配置应如下所示

# Virtual Host configuration for tnconnect
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#

map $http_upgrade $type {
    default "web";
    websocket "wss";
}

server {

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/your.domain.com/public;

    charset utf-8;

    error_page 404 /index.php;

    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Frame-Options "SAMEORIGIN";

    # Add index.php to the list if you are using PHP
    index index.php;
    server_name your.domain.com;

    location / {
        try_files /nonexistent @$type;
    }

    location @web {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ /index.php?$args;
    }

    location @wss {
        proxy_pass http://127.0.0.1:6001;
        proxy_set_header Host $host;
        proxy_read_timeout 60;
        proxy_connect_timeout 60;
        proxy_redirect off;

        # Allow the use of websockets
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny all;
    }

    ssl on;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/your.domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/your.domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = your.domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80 default_server;
    listen [::]:80 default_server;
    server_name your.domain.com;
    return 404; # managed by Certbot
}

您的 .env 文件应如下所示

# .env
REVERB_APP_ID=local
REVERB_APP_KEY=local
REVERB_APP_SECRET=local
REVERB_HOST=your.domain.com
REVERB_SCHEME=https
REVERB_PORT=443

这确保了 nginx 处理您的请求,如果您在同一服务器上运行多个 websockets 实例,nginx 将处理到正确实例的请求。

如果您只有一个 websockets 实例运行,您可以使用默认端口 6001 并从您的 .env 文件中删除 PUSHER_PORT

# .env
REVERB_APP_ID=local
REVERB_APP_KEY=local
REVERB_APP_SECRET=local
REVERB_HOST=0.0.0.0
REVERB_PORT=8080
REVERB_SCHEME=http

这不会通过 nginx 处理,而是由 websocket 服务器直接处理。