聞きたい内容
Symfony3で下記の通り
- コントローラー
- エンティティ
- その他諸々のライブラリインストール(FOSRestBundleなど)
を実施しましたが、実際にWeb画面からアクセスしようとするとできない状態です(localhost/usersにアクセスで404エラーとなってしまいます。デフォルトページは表示される)
実際に実装したコードは下記の通りなのですが、 ルーティングの部分の {_format}
の部分の意味がわかりません。
どなたか参考文献やWebサイトなどありましたら教えてほしいです。
- UsersController.php
<?php namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use FOS\RestBundle\Controller\FOSRestController; class UsersController extends FOSRestController { public function getUserAction($id) { return "Hello world"; } }
- User.php
<?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use FOS\UserBundle\Model\User as BaseUser; /** * @ORM\Entity * @ORM\Table(name="`user`") */ class User extends BaseUser { /** * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * @ORM\Column(type="integer") */ protected $id; public function getId() { return $this->id; } }
- routing.yml
app: resource: '@AppBundle/Controller/' type: annotation users: type: rest resource: '@AppBundle/Controller/UsersController.php'
- bin/console debug:route
-------------------------- -------- -------- ------ ----------------------------------- _wdt ANY ANY ANY /_wdt/{token} _profiler_home ANY ANY ANY /_profiler/ _profiler_search ANY ANY ANY /_profiler/search _profiler_search_bar ANY ANY ANY /_profiler/search_bar _profiler_phpinfo ANY ANY ANY /_profiler/phpinfo _profiler_search_results ANY ANY ANY /_profiler/{token}/search/results _profiler_open_file ANY ANY ANY /_profiler/open _profiler ANY ANY ANY /_profiler/{token} _profiler_router ANY ANY ANY /_profiler/{token}/router _profiler_exception ANY ANY ANY /_profiler/{token}/exception _profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css _twig_error_test ANY ANY ANY /_error/{code}.{_format} homepage ANY ANY ANY / get_user GET ANY ANY /users/{id}.{_format} ★この.{_format}の意味 -------------------------- -------- -------- ------ -----------------------------------
あなたの回答
tips
プレビュー