问题标签 [fastroute]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1778 浏览

php - FastRoute:将路由前缀传递给处理程序

例如,假设我有这条路线。

以下是我处理路由、调用控制器及其方法的方法。

如何将 {slug} 传递给控制器​​方法?它在其文档中没有提及任何有关它的信息,也无法通过谷歌搜索找到有关它的信息。

0 投票
0 回答
101 浏览

php - 未找到 PHP 无框架教程类

我尝试使用PatrickLouys/no-framework-tutorial My Controllers/BaseController.php 构建测试项目:

和 index.php 文件:

当我尝试运行此代码时,出现错误:

找不到类“示例\控制器\BaseController”

你能告诉我我在哪里做错了吗?

0 投票
0 回答
504 浏览

php - 如何将参数传递给 FastRoute 中的控制器?

我没有找到任何与Lumen(不是 Laravel)相关的东西来将值传递给控制器​​。我的方法是错误的还是我只是错过了显而易见的事情?

我想将参数传递给控制器​​,而不是谈论{name}in localhost:8000/someprefix/{name}。由于 lumen 正在使用FastRoute,我不想改回默认路由器。我想将值作为方法参数传递给控制器​​?任何帮助将不胜感激。

网页.php

用户控制器.php

0 投票
1 回答
307 浏览

rest - Create an api using lumen and neo4j

I want to create an api rest using lumen that it will comunicate with neo4j, for this purpose I'm using NeoEloquent. I've already read the NeoEloquent's documentation but I'm confused. I've understand how lumen it work with a relational database, there is a model, a controller, every action that I want to do on my db pass through a routes that specify the method to use, but I don't understand how this work with a graph database. In particular I don't understand how can I create new label, retrieve all label and relationship using the Http methods. I've try to follow the same procedure that it's explain in this guide (clearly readapting it to my use case) but without success.

Example

Let we say that we have two labels with a many to many relationship, this labels will be Exhibit and Zone. We want to retrieve the zone that is associate to the Exhibit that has a specific identificator. So, the query will be something like this:

For do this query we need to have this routes that it has to present in web.php file:

With this routes we are saying: when come a request with a get method, go inside the ExhibitController class and call the retrieveZone function. This is what is present in controller class:

When we call retrieveZone function, we will call the function findZone as well that is present in Exhibit model:

The Zone class:

This is what I've done for translate the query using NeoEloquent, Lumen and Fastroute, but the result is 500 Internal Server Error.

Stack Trace

0 投票
1 回答
304 浏览

rest - 使用流明检索边缘和关系属性

我是 lumen 和 neo4j 的新手,我想为两个标签之间的特定关系添加一些属性。

例如,如果我们假设Exhibit标签和以坐标属性为特征的区域标签之间存在多对多关系,我如何检索坐标属性?

阅读neoEloquent 文档,我了解到要检索两个标签之间的边缘,我必须遵循函数findZone中存在的过程:

问题是,当我测试这个函数时,结果是一个空响应,但我确信标签之间有一个边缘。

我错了还是 findZone 函数可以在 Cypher 中翻译为这个查询?

编辑

正如用户 Sven Hakvoort 建议我的那样,我有改变

现在响应是 500 内部错误,堆栈跟踪:

0 投票
0 回答
114 浏览

php - Heroku:只有“/”在我的 php 应用程序上工作

我使用 php fast-route在Heroku免费网络测功机上处理我的应用程序的路由。该应用程序未使用任何框架。

只有 / 页面有效。其余的不工作。尽管它们在我的本地服务器上正常工作。

如果我尝试访问登录页面https://creationspace.herokuapp.com/login它返回 404 错误 - 找不到页面。

这是我的 Procfile

路由.php

请我需要帮助。

0 投票
2 回答
121 浏览

rest - 使用 Lumen 和 NeoEloquent OGM 从 Neo4j 检索 DateTime

语境

我正在创建一个 api rest,它与已经由节点和边填充的图形数据库接口,该节点和边描述了事件和展览在几个以区域为特征的博物馆内的位置。特别是在展览和区域之间存在一些边缘,这些边缘具有开始时间和坐标等属性。开始时间是一个符合DateTime neo4j 格式的属性,下面是一个例子:

我创建边缘的方式是:

其中展览和区域分别是节点 ID。

问题

我想从特定边缘检索 start 属性,但结果如下:

代码

findZone 函数产生问题:

我试图只给边缘坐标属性,当我用坐标函数替换开始属性时。

堆栈跟踪

0 投票
1 回答
1564 浏览

php - PHP - Middlewares\FastRoute 包的 nikic/FastRoute 路由

我有这些路线:

我正在使用Middleware\FastRoute,Middle\RequestHandlerRelay包来制作请求处理程序。我也在使用php-diDI 容器。

我的问题是,如果我想使用上面提到的路线,我给了我这个错误:

Deprecated: Non-static method SuperBlog\Controller\ArticleController::show() should not be called statically in

当我不使用方法(如['GET', '/', 'SuperBlog\Controller\HomeController'],)时,它运行良好。

我的问题是我怎样才能让它工作?没有找到任何解决方案。我知道如果我将show方法设为静态它会起作用,但我认为这不是一个好主意。

引导程序.php

文章控制器.php

路由.php

0 投票
2 回答
637 浏览

php - wrk 基准测试工具对于测试最快的 php 框架是否可靠

所以我尝试在我的本地主机(6 岁的 i7 电脑)上测试 php 框架,使用:

  • 没有数据库的 Laravel 我得到了:每秒 698 个请求
  • Cakephp:1,400 rps
  • Swoole:197,000 rps
  • Swoole 与 API 的中间件(fastroute 等):176,000 rps

在此处输入图像描述

是否wrk可靠,我可以告诉我的老板我的 api 每秒可以处理 170k 请求?

0 投票
0 回答
35 浏览

laravel - 流明将特定组的所有路线指向 *

我正在开发一个网站,其中包含简单的登录页面和一些其他页面,例如联系人和新闻作为前端(使用普通的 PHP 和流明应该就足够了)和 vuejs 作为后端。尝试将所有获取请求从“/admin/”发送到视图(“admin”)。这是我能想到的最好的...

问题是我所做或访问的所有 url,我得到的所有获取请求响应都是 404 - 未找到。甚至在流明日志甚至错误日志 apache 服务器中都没有任何日志或任何内容。我哪里做错了?

//使用流明,因为我需要用于 vuejs 操作的 API。