未加载资产

问题描述 投票:1回答:1

我有问题,我的资产未加载-找不到404

"nelmio/api-doc-bundle": "^3.6@dev"

我执行了php bin/console assets:installphp bin/console assets:install --symlink

Locally有效,但是在test server上无效...有人可以对此有所了解吗?

本地要求网址:http://symfony.localhost/bundles/nelmioapidoc/swagger-ui/swagger-ui-bundle.js-正确加载

在测试服务器上http://11.11.11.11/bundles/nelmioapidoc/swagger-ui/swagger-ui.css未加载

并返回错误

in /var/www/symfony/vendor/friendsofsymfony/rest-bundle/View/ViewHandler.php (line 163)
Format 'html' not supported, handler must be implemented

我检查/var/www/symfony/public/bundles中的文件,看起来正确,nelmioapidoc中存在的文件。我错过了什么?

fos其余配置:

fos_rest:
    body_listener:
        service: my_body_listener
    unauthorized_challenge: "Basic realm=\"Restricted Area\""
    access_denied_listener:
        # all requests using the 'json' format will return a 403 on an access denied violation
        json: true
    param_fetcher_listener: force
    format_listener:
        rules:
            - { path: ^/api, prefer_extension: true, fallback_format: json, priorities: [ json ] }
            - { path: ^/, priorities: [ json, xml, html ], fallback_format: ~, prefer_extension: true }
    view:
        view_response_listener: 'force'
        formats:
            json: true
            jsonp: false
            xml: false
            rss: false
        mime_types:
            json: ['application/json', 'application/x-json']
    routing_loader:
        default_format:  json
    exception:
        enabled: true
        codes:
            'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
            'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
            'Symfony\Component\HttpKernel\Exception\BadRequestHttpException': 400
        messages:
            Symfony\Component\HttpKernel\Exception\BadRequestHttpException: true
            Symfony\Component\HttpKernel\Exception\HttpException: true

但是我想这与fos休息无关。因为这是资产性资源,所以应加载它而不进行处理。最重要的是,本地炒锅没有任何问题

另一件事,也许是服务器出现问题。我将Docker与nginx映像一起使用。这是我的conf nginx.conf:

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
  worker_connections  2048;
  multi_accept on;
  use epoll;
}

http {
  server_tokens off;
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 15;
  types_hash_max_size 2048;
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  access_log off;
  error_log off;
  gzip on;
  gzip_disable "msie6";
  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
  open_file_cache max=100;
  client_body_temp_path /tmp 1 2;
  client_body_buffer_size 256k;
  client_body_in_file_only off;
}

daemon off;

和主机

server {
    server_name symfony.localhost;
    root /var/www/symfony/public;


    location / {
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /index.php/$1 last;
    }

    location ~ ^/index\.php(/|$) {
        fastcgi_pass php-upstream;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
    }

    error_log /var/log/nginx/symfony_error.log;
    access_log /var/log/nginx/symfony_access.log;
}
php symfony fosrestbundle nelmioapidocbundle
1个回答
0
投票

您的配置中view_response_listener是否设置为true

© www.soinside.com 2019 - 2024. All rights reserved.