Using the ::class keyword in Laravel

Christoph Rumpel has a new tutorial on using the ::class keyword in PHP and Laravel.

Since PHP 5.5 the class keyword is used for class name resolution. This means it returns the fully qualified ClassName. This is extremely useful when you have namespaces, because the namespace is part of the returned name.

Christoph goes through a few examples and demonstrates how this limits errors by utilizing the IDE’s auto setting of namespaces.

Filed in: Laravel Tutorials


Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Software Developer
Remote (US & Canada)
๐Ÿ˜Ž Laravel Developer
Jogg, Inc
Junior, Mid, and Senior Software Engineers. Laravel / Vue. Saint Petersburg, FL
Saint Petersburg, FL and Remote
Senior PHP Developer (Laravel)
The Interaction Design Foundation
Fullstack Laravel Engineer (Munich/Remote) ๐Ÿ’ป
Munich, Germany or Remote