DEV Community

Discussion on: Alternatives to using a constants.php file in your Laravel project

Collapse
 
plweil profile image
Peter Weil

I really like the class-based constants idea, as opposed to dumping everything into the constants file. Compare, for example,

return $this->status === config('constants.status.published')
Enter fullscreen mode Exit fullscreen mode

or even

return $this->status === config('status.published')
Enter fullscreen mode Exit fullscreen mode

with

return $this->status === Status::PUBLISHED
Enter fullscreen mode Exit fullscreen mode