skip to Main Content

In a tutorial on Laravel (*1) it is said that the controller name should be plural instead of singular. I am surprised because Laravel always generates the controller automatically in singular. There was also the question in 2018 in the Laravel Context here in the SO (*2). Has anything changed here in this regard? Is there a general valid statement here or is this a matter of taste. For me personally, singular makes total sense.

*1 https://youtu.be/L1owEfA9ioc?t=148

*2 laravel controller name should be plural or singular?

2

Answers


  1. The Laravel community has agreed upon the following list of naming conventions. This states that the name of the controller should be singular, while you are free to choose another convention if it suits your needs or the preferences of your team.

    Login or Signup to reply.
  2. In a single sentence? It should be singular. because Laravel has its own way of doing things. If you type PHP artisan make:model Todo -a you’ll be able to see that Laravel creates everything as singular except migrations. why? because there will be multiple items on a table.

    php artisan stub:publish will get you the templates of all the component which you can customize although i don’t recommend it meddling with it if you’re a beginner.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search