Skip to content

Find Text in Files in Laravel

By Jasper Frumau

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.

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

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.