laravel controller name should be plural or singular? laravel controller name should be plural or singular? laravel laravel

laravel controller name should be plural or singular?


Here is a list of naming conventions accepted by Laravel community. According to this, Controller name should be Singular although you could chose your own convention as your need or how your team prefer.


You should follow those naming convention:

  1. Model Name should be singular e.g: 'Profile', not 'Profiles'
  2. Controller name should be singular with 'Controller' suffix e.g:'ProfileController', not 'ProfilesController'
  3. Php class Name should be in 'StudlyCase' format e.g: 'TestClass'
  4. Php function Name should be in 'camelCase' format e.g:'testFunction'
  5. Class constants MUST be declared in all upper case with underscoreseparators; for example:

    class Foo{    const VERSION = '1.0';    const DATE_APPROVED = '2012-06-01';}

Useful link:

https://www.php-fig.org/psr/psr-1/


Plural. Although the official laravel docs use singular for controller names, it is very well known that most of prominent laravel developers such as Jeffrey Way, Adam Wathan, Chris Fidao and many others uses plural for controller names that it sort of become the actual standard.

You are far better off using plural so you feel less confusion when you watch their videos, read their blog posts.etc