Symfony 托管在 heroku 中,出现 Sqlite 错误
Symfony hosted in heroku with SqlLite error
Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: "No route found for "GET http://task-demi.herokuapp.com/api/register": Method Not Allowed (Allow: POST)" at /app/vendor/symfony/http-kernel/EventListener/RouterListener.php line 140
所以我已经在 heroku 中上传了我的 Symfony 5。
它在 localhost 中运行良好,没有错误,但是在 Heroku 中托管后我得到了上述错误。
我用过 SqlLite
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
doctrine_heroku.yaml
doctrine:
dbal:
driver: 'pdo_sqlite'
server_version: '3.15'
如何解决?
你安装了吗symfony/apache-pack
。它允许您访问应用程序中的任何 URL,而无需在路径中包含 /index.php。
为了快速启用 Apache 网络服务器的重写,您可以安装 symfony/apache-pack 配方,它将合适的 .htaccess 文件放入您的 public/ 目录:
composer require symfony/apache-pack
git add composer.json composer.lock symfony.lock public/.htaccess
git commit -m "apache-pack"
来源:Heroku
Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: "No route found for "GET http://task-demi.herokuapp.com/api/register": Method Not Allowed (Allow: POST)" at /app/vendor/symfony/http-kernel/EventListener/RouterListener.php line 140
所以我已经在 heroku 中上传了我的 Symfony 5。 它在 localhost 中运行良好,没有错误,但是在 Heroku 中托管后我得到了上述错误。 我用过 SqlLite
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
doctrine_heroku.yaml
doctrine:
dbal:
driver: 'pdo_sqlite'
server_version: '3.15'
如何解决?
你安装了吗symfony/apache-pack
。它允许您访问应用程序中的任何 URL,而无需在路径中包含 /index.php。
为了快速启用 Apache 网络服务器的重写,您可以安装 symfony/apache-pack 配方,它将合适的 .htaccess 文件放入您的 public/ 目录:
composer require symfony/apache-pack
git add composer.json composer.lock symfony.lock public/.htaccess
git commit -m "apache-pack"
来源:Heroku