laravellaravel-blade

Laravel naming convention for blade files


I know that naming conventions in Laravel is covered in another question, but blade files are not covered there. I read several blogs and forums and they all offer different approach so I want to ask here:

My controller method is AdminController@listPropertyTypes - which lists and manages the property types..

One blog suggests:

/resources/views/admin/property/types.blade.php

Another blogs suggest underscore or no space:

/resources/views/admin/property_types.blade.php
/resources/views/admin/propertytypes.blade.php

I would personally named this way since it is a view:

/resources/views/admin/property-types.blade.php

Is there a best practice or PSR rule for this?


Solution

  • EDIT: Laravel community mostly use kebab-case or camelCase

    ie views/admin/property-types.blade.php or views/admin/propertyTypes.blade.php

    Laravel's creator seems to use kebab-case, but Spatie recommends camelCase.

    As @MrEduar explained it, there is no strict convention.

    NB: https://www.laravelbestpractices.com website is abandonned and not affiliated with Laravel.


    OLD: Initial answer

    I came across Laravel Best Practices.

    Laravel : Best Practices aims to put together all the resources and best practices in using the Laravel Framework. Last Updated: 2020-05-07 12:26:48

    Views

    You SHOULD use snake_case as file name of your Blade templates

    Good

    show_filtered.blade.php
    

    Bad

    showFiltered.blade.php
    show-filtered.blade.php