【问题标题】:PHP built-in web server is not finding assetsPHP 内置 Web 服务器未找到资产
【发布时间】:2016-09-23 08:55:57
【问题描述】:

我有一个使用 Zend Framework 2 构建的 php 项目。想要启动内置服务器以使用以下命令进行开发:

sudo php -S localhost:8080 -t public/ public/index.php

Zend Frameowrk 2 的所有功能都运行良好,但检索资产时出现 404 错误。

资产位于public/css、public/img 和public/js 文件夹中。 GET http://localhost:8080/css/bootstrap.css [HTTP/1.1 404 Not Found 10ms] GET http://localhost:8080/css/dlu-tw-bootstrap.css [HTTP/1.1 404 Not Found 21ms] GET http://localhost:8080/css/style.css [HTTP/1.1 404 Not Found 35ms] GET http://localhost:8080/js/bootstrap.js [HTTP/1.1 404 Not Found 45ms]

知道如何允许内置服务器访问这些文件吗?

【问题讨论】:

    标签: php zend-framework2 assets php-builtin-server


    【解决方案1】:

    正如我从阅读 this blog post 中了解到的那样,您要么需要从正确的文件夹启动命令,而不是指定任何 -t 选项

    $ cd public
    $ sudo php -S localhost:8080
    

    或者你需要在index.php写自己的路由规则

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-09
      • 2022-01-18
      • 1970-01-01
      • 2021-11-21
      • 2015-06-13
      • 2017-03-04
      相关资源
      最近更新 更多