Find Text in Files in Laravel

Sometimes you need to quickly find a text / string of text inside your Laravel app. And sometimes apps you use do not do the job well or skip folders like the vendor folder directly. Then you can in fact use the old fashioned command line and built in Unix tools. This can be easily done with this Unix command grep and the proper syntax.


The syntax should be as follows:

grep -rnw "text" path/to/ 

This way you can add the string you look for and the path you want go for. A bit more complicated than my favorite

history |grep something


Example to search for imagick in the Laravel vendor Intervention directory would be:

grep -rnw "imagick" vendor/intervention

This run from the application root of course. The r is for recursive, n for adding finds on newlines and w for searching for it as a word.

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.