使用PhpStorm进行编码时,在Laravel 5.3中组织View文件的有效方法

I don't know if this question qualifies to be in SO, but since PhpStorm became de facto the IDE to develop in Laravel framework, this could be helpful to many of us. Since file naming in Laravel is a big deal, I was wandering what would be a proper/efficient/logical way to name View files.

Lets say I declare all my routes in web.php. I have multiple tables, all named as word in plural like articles. So I have Article model and ArticleController resource controller. Controller consist of standard RESTful and nonstandard routes.

The way I wanted to name my View files is pretty much straightforward and logical, eg:

  • for home in web.php I have /resources/views/home.blade.php and define it with view('home')
  • for index in ArticleController I have /resources/views/articles/index.blade.php and define it with view('articles.index')
  • for show in ArticleController I have /resources/views/articles/show.blade.php and define it with view('articles.show')etc...

Problem arise when I want to use famous PhpStorm CTRL+SHIFT+N open by file search, I get filenames with the same filename, like show.blade.php. As far as I know, there is no way to search by a path name...

So, I decided to rename my filenames to articles_show.blade.php, articles_index.blade.php, but pretty soon I my views folder was overcrowded. I have considered articles/articles_show.blade.php pattern, but it's not following DRY principle and look ugly when defined.

Do any of you managed to develop a solution for efficient and logical naming convention? How do YOU organize your view files?

P.S. I still use original pattern for vendor views, like auth/login.blade.php, auth/register.blade.php. Layouts files also follows that pattern: layouts/app.blade.php (popular layout name), layouts/header.blade.php, layouts/footer.blade.php. But it's obvious, these filenames will not be repeated, so no problem with search function. I want to also mention, that for most tables/controllers/models I have a special loop view file, that is not bound to any function or route, and named by established pattern, like articles_loop.blade.php.

It looks like you can search for a filename by a path! Kudos to @LazyOne, since he pushed me in the right direction.

So, in order to search for a filename within a path using a partial match, all you need to do is suffix a partial path name with "/" and type in a partial of your filename.

So in order to find /resources/views/articles/show.blade.php, you can put either:

  • ar/sh
  • vi/ow
  • ar/shbl (notice how I used two partial sh and bl to find show.blade.php without any separator whatsoever).

etc..