我的routing.yml:找不到路線,Symfony的路由更新不及時正確
user_user:
resource: "@UserUserBundle/Resources/config/routing.yml"
prefix: /user
book_book:
resource: "@BookBookBundle/Resources/config/routing.yml"
prefix: /book
index_index:
resource: "@IndexIndexBundle/Resources/config/routing.yml"
prefix: /
app:
resource: "@AppBundle/Controller/"
type: annotation
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
app_api:
resource: "@AppBundle/Controller/Api"
type: annotation
mvms_api:
type: rest
prefix: /api
resource: "@AppBundle/Resources/config/api-routing.yml"
我
API-的routing.yml:
blog_api_articles:
type: rest
resource: "@AppBundle/Controller/ArticlesController.php"
name_prefix: api_article_
blog_api_reviews:
type: rest
resource: "@AppBundle/Controller/ReviewsController.php"
name_prefix: api_reviews_
api_reviewsPut:
type: rest
resource: "@AppBundle/Controller/PutController.php"
name_prefix: api_put_
我的PHP斌/控制檯調試:路由器
...
api_article_get_article GET ANY ANY /api/articles/{id}.{_format}
api_reviews_get_review GET ANY ANY /api/reviews/{id}.{_format}
當我在API-routing.yml中的應用進入新的路線只是不刻意去參加我的API路由中的最後一項似乎並沒有被工作/顯示...
//This works fine
class ReviewsController extends Controller
{
/**
* Note: here the name is important
* get => the action is restricted to GET HTTP method
* Article => (without s) generate /articles/SOMETHING
* Action => standard things for symfony for a controller method which
* generate an output
*
* it generates so the route GET .../articles/{id}
*/
public function getReviewAction($id)
{
$someId = $id;
$rv = $this->getDoctrine()->getManager();
$review = $rv->createQuery(
'SELECT * FROM AppBundle:Something r WHERE r.id= :id')->setParameter('id', $someId);
$reviews = $review->getResult();
if (empty($reviews)) {
return array('Data' => 'none');
}
else
return $reviews;
}
}
class PutController
{
public function putReviewsPut($id)
{
$someId = $id;
$rv = $this->getDoctrine()->getManager();
$review = $rv->createQuery(
'some query')->setParameter('id', $someId);
$reviews = $review->getResult();
if (empty($reviews)) {
return array('Data' => 'none');
}
else
return $reviews;
}
}
他們考慮在內。 因此我得到GET/API「未找到\路徑」 /把/ 1 \「」, 在郵差
我試圖重新啓動服務器 而且還試圖 PHP斌/控制檯高速緩存:明確 - env prod
在Windows 10上運行Xampp並使用phpStorm進行編輯。
昨晚我和api_reviews_的問題完全一樣,但不知何故,它決定最終工作。
你嘗試清除緩存? –
@ImanaliMamadiev Yep –
它與複數有關......最終需要有一個S。我會詳細說明,如果我理解它 –