Comments (9)
dashes are fine convention for 'all lower cases' in url string. You can combine dashes and slashes to separate those words by their nature. For example, if you have resource controller and want to add additional route
Route::post('product-details/fetch', 'ProductDetailController@fetch')->name('product_details.fetch');
Route::resource('product-details', 'ProductDetailController');
This way you are following convention of already meant resource routes.
from laravel-best-practices.
@upeksha1996 go with master-products
. https://restfulapi.net/resource-naming/
from laravel-best-practices.
In the laravel documentation, I found out kebab case also.
Route::get('/forgot-password', function () { return view('auth.forgot-password'); })->middleware(['guest'])->name('password.request');
I like to use underscored formations in PHP because it cut off technical debt if in future I have to name variables by it (directory name in this case). Same for PHP, JS or DB (MySQL that I use) having variables can be with underscores but can't with dash. This way I just remove unnecessary limitation. Consider you want for some reason to extend DB and you find yourself in need to create table by concrete directory (these are hypothetical presumptions). It is good to have some string in name that you can easily manage to create variable name from it or to have well consistency between names. This can be broad thinking and it is actually the same for PHP: whether it is -
whether _
but for developer's future use it's easier to be _
imho.
from laravel-best-practices.
I guess both underscored and camelCase are ok since you can select view names by using double-click in most IDEs.
from laravel-best-practices.
@upeksha1996 I don't think there is a convention. I saw a lot of different name styles for views in real-life projects and packages.
from laravel-best-practices.
Thank you so much for replies.. Can you also please let me know whether there is a naming convention for view folders? whether the respective folder for the MasterProductController is better to be masterProducts
, master-products
, master_products
?
from laravel-best-practices.
I use underscored variant with addition that it is singular in my case.
So MasterProductController
relates with views/master_product
directory.
from laravel-best-practices.
In the laravel documentation, I found out kebab case also.
Route::get('/forgot-password', function () {
return view('auth.forgot-password');
})->middleware(['guest'])->name('password.request');
from laravel-best-practices.
@alexeymezenin what do you think?
from laravel-best-practices.
Related Issues (20)
- What PHP to JS package is recommended? HOT 4
- How about throw exceptions? HOT 5
- Do not get data from the .env file directly, why? HOT 2
- What about laravel Resources? HOT 3
- Wrong return type? HOT 1
- PSR-12 HOT 3
- What about translation variables? HOT 2
- Best
- Interface best practice HOT 5
- Converting from and back to json HOT 1
- Validation FormRequest HOT 1
- Looking for the repo owner HOT 8
- Typo Issue in example (Don't repeat yourself (DRY)) HOT 2
- Store dates in the standard format. Use accessors and mutators to modify date format HOT 11
- Seeder in singular -> Good, Seeder in plural -> bad (naming-conventions) HOT 2
- Recommended route name conflict?
- A tool that enforces all these best practices HOT 1
- Change test case methods to snake_case HOT 1
- Query Parameter Validation HOT 1
- La
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-best-practices.