I'd like all my Controller action routes in the namespace 'App\Controller\Api' to have the prefix '/api'. I also want to use annotations inside the controllers to set the rest of the route.
In Symfony 3 this was done by editing 'config/routing.yml':
app:
resource: '@AppBundle/Controller/Api'
type: annotation
prefix: /api
How can I do this in Symfony 4? Do I need to make a bundle? Which config file would I use since I don't have a 'config/routing.yml'?
Ok It looks like I should have just tried real path names. The following worked in 'config/routes.yaml':
api:
prefix: /api
resource: '../src/Controller/Api'
At first run composer require annotations and then
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/blog")
*/
class BlogController extends Controller
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With