Why "create the app/Http/Controllers/API directory"?

I purchased your ebook (which is probably one of the best I ever read) and I came to a basic a question.

In page 20. Step 4: Add Directories for Controllers and Models it says

“First, we will need to create the app/Http/Controllers/API directory. This
directory will house all of the API controllers that respond to API routes. It will
allow for a nice clean namespace for all of our API components.”

Isn’t the API directory already there with any Laravel installation ? Next to the web directory?

Why do we need to create a new one?


Hi @happyariel ,

Thanks for the kind words on the E-Book!

On a default install of Laravel 8, there isn’t a sub directory for the API controllers: laravel/app/Http/Controllers at 8.x · laravel/laravel · GitHub. I add that in order to have a more organized structure for our controllers. At the point in the book, I’m just setting up my preferred structure by adding extra directories so when the time comes to implement a feature you just drop it into the the right directory.

Hope that helps!